Upload data
Hosted
- Typescript
- Python
- Java
- PHP
- Golang
import {
AvailabilityClient,
Bloock,
HostedPublisher,
RecordClient,
} from '@bloock/sdk';
Bloock.setApiKey(process.env['API_KEY']);
const recordClient = new RecordClient();
const availabilityClient = new AvailabilityClient();
const record = await recordClient.fromString('Hello world').build();
const _id = await availabilityClient.publish(record, new HostedPublisher());
// it returns an uuid to further retrieve it
console.log('Record was published successfully');
import os
from bloock import bloock
from bloock.client.record import RecordClient
from bloock.client.availability import AvailabilityClient
from bloock.entity.availability.hosted_publisher import HostedPublisher
if __name__ == "__main__":
bloock.api_key = os.environ["API_KEY"]
record_client = RecordClient()
availability_client = AvailabilityClient()
record = record_client.from_string("Hello world").build()
id = availability_client.publish(record, HostedPublisher())
print("Record was published successfully")
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.AvailabilityClient;
import com.bloock.sdk.client.RecordClient;
import com.bloock.sdk.entity.availability.HostedPublisher;
import com.bloock.sdk.entity.record.Record;
public class PublishHosted {
public static void main(String[] args) throws Exception {
try {
Bloock.apiKey = System.getenv("API_KEY");
RecordClient recordClient = new RecordClient();
AvailabilityClient availabilityClient = new AvailabilityClient();
Record record = recordClient.fromString("Hello world").build();
String id = availabilityClient.publish(record, new HostedPublisher()); // it returns the hash
} catch (Exception e) {
System.out.println(e);
}
}
}
<?php
require "./vendor/autoload.php";
use Bloock\Bloock;
use Bloock\Client\AvailabilityClient;
use Bloock\Client\RecordClient;
use Bloock\Entity\Availability\HostedPublisher;
Bloock::$apiKey = getenv("API_KEY") ?: "";
$recordClient = new RecordClient();
$availabilityClient = new AvailabilityClient();
$record = $recordClient->fromString("Hello world")->build();
$id = $availabilityClient->publish($record, new HostedPublisher());
print "Record was published successfully\n";
package main
import (
"fmt"
"log"
"os"
bloock "github.com/bloock/bloock-sdk-go/v2"
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/availability"
)
func main() {
bloock.ApiKey = os.Getenv("API_KEY")
recordClient := client.NewRecordClient()
availabilityClient := client.NewAvailabilityClient()
record, err := recordClient.FromString("Hello world").Build()
if err != nil {
log.Fatalln(err)
}
_, err = availabilityClient.Publish(record, availability.NewHostedPublisher())
if err != nil {
log.Fatalln(err)
}
fmt.Println("Record was published successfully")
}
IPFS
- Typescript
- Python
- Java
- PHP
- Golang
import {
AvailabilityClient,
Bloock,
IpfsPublisher,
RecordClient,
} from '@bloock/sdk';
async function main() {
Bloock.setApiKey(process.env['API_KEY']);
const recordClient = new RecordClient();
const availabilityClient = new AvailabilityClient();
const record = await recordClient.fromString('Hello world').build();
const _id = await availabilityClient.publish(record, new IpfsPublisher());
// it returns an uuid to further retrieve it
console.log('Record was published successfully');
}
main();
import os
import bloock
from bloock.client.record import RecordClient
from bloock.client.availability import AvailabilityClient
from bloock.entity.availability.ipfs_publisher import IpfsPublisher
if __name__ == "__main__":
bloock.api_key = os.environ["API_KEY"]
record_client = RecordClient()
availability_client = AvailabilityClient()
record = record_client.from_string("Hello world").build()
id = availability_client.publish(record, IpfsPublisher())
print("Record was published successfully")
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.AvailabilityClient;
import com.bloock.sdk.client.RecordClient;
import com.bloock.sdk.entity.availability.IpfsPublisher;
import com.bloock.sdk.entity.record.Record;
public class PublishIpfs {
public static void main(String[] args) throws Exception {
Bloock.apiKey = System.getenv("API_KEY");
RecordClient recordClient = new RecordClient();
AvailabilityClient availabilityClient = new AvailabilityClient();
Record record = recordClient
.fromString("Hello world")
.build();
String id = availabilityClient.publish(record, new IpfsPublisher());
System.out.println("Record was published successfully");
}
}
<?php
require "./vendor/autoload.php";
use Bloock\Bloock;
use Bloock\Client\AvailabilityClient;
use Bloock\Client\RecordClient;
use Bloock\Entity\Availability\IpfsPublisher;
Bloock::$apiKey = getenv("API_KEY") ?: "";
$recordClient = new RecordClient();
$availabilityClient = new AvailabilityClient();
$record = $recordClient->fromString("Hello world")->build();
$id = $availabilityClient->publish($record, new IpfsPublisher());
print "Record was published successfully\n";
package main
import (
"fmt"
"log"
"os"
bloock "github.com/bloock/bloock-sdk-go/v2"
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/availability"
)
func main() {
bloock.ApiKey = os.Getenv("API_KEY")
recordClient := client.NewRecordClient()
availabilityClient := client.NewAvailabilityClient()
record, err := recordClient.FromString("Hello world").Build()
if err != nil {
log.Fatalln(err)
}
_, err = availabilityClient.Publish(record, availability.NewIpfsPublisher())
if err != nil {
log.Fatalln(err)
}
fmt.Println("Record was published successfully")
}