Simple uploads
How can I upload files to Akord's Arweave storage? How can I upload files to Akord's cloud storage?
Example 1.1. Minimal upload
curl --location 'https://api.akord.com/files' \
--header 'Accept: application/json' \
--header 'Api-Key: your_api_key' \
--header 'Content-Type: text/plain' \
--data '@/path/to/your/file.txt'const fs = require('fs').promises;
const data = await fs.readFile('/path/to/your/file.txt', 'utf8'); //nodejs specific
const response = await fetch('https://api.akord.com/files', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Api-Key': 'your_api_key',
'Content-Type': 'text/plain'
},
body: data
})import requests
with open('/path/to/your/file.txt', 'r', encoding='utf-8') as file:
data = file.read()
response = requests.post(
url='https://api.akord.com/files',
headers={
'Accept': 'application/json',
'Api-Key': 'your_api_key',
'Content-Type': 'text/plain'
},
data=data
)Thats it! You just uploaded the file to Arweave. Here is the example response:
{
"id": "a6f1fbfc-403d-4607-b648-4b949fdd50bd",
//technical id of upload. can be used to get metadata of the upload or file binary from cloud storage
"mime_type": "text/plain", //depends on content-type of upload, goes as a tag
"sizeInBytes": 10,
"cloud": {
"uri": "a6f1fbfc-403d-4607-b648-4b949fdd50bd", //same as ID
"url": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd" //url to binary served from cloud storage
},
"tx": {
"id": "LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", //fixed ID of Arweave transaction (ANS-104 data item ID)
"status": "scheduled",
//indicates where is your file in Arweave bundling context
//scheduled - file is in our cloud storage and is scheduled for ANS-104
//verification - file is being verified for malicious content
//blocked - file is recognized as malicious, won't go to Arweave
//pending - file was bundled and posted to Arweave
//confirmed - file is confirmed on Arweave
//rejected - this indicates a technical problem with our bundling service)
"tags": [], //your Arweave tags appended to transaction
"statusUrl": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd/status", //check file status endpoint, returns simillar JSON schema
"gatewayUrls": [
"https://akrd.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E",
//our instance of Arweave gateway - this url will work always, even right after upload since it falls back to cloud storage when file is not yet on Arweave
"https://arweave.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E"
// other Arweave gatways
]
"viewblockUrl": "https://viewblock.io/arweave/tx/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", //see your file on Viewblock - this url will only work when file is in 'committed' status & indexed by Viewblock
"info": "Transaction is visible on the blockchain indexers when in the \"committed\" status.",
"infoUrl": "https://docs.akord.com/api-and-dev-tools/build/akord-api/files"
}
}Example 1.2. Upload with Arweave transaction tags
To add tags to your Arweave transaction - use query params. Each query param with key prefixed with tag- is treated as Arweave transaction tags. Tags query params are case sensitive. E.g.
tag-file-category=photo => Tag name: 'file-category', Tag value: 'photo'
Tag-File-Category=PHOTO => Tag name: 'File-Category', Tag value: 'PHOTO'
Example 1.3. Upload with Arweave transaction tags (encoded)
You may encode your tags as base64 string and pass it as a single param
Example 2. Upload to cloud storage
The request above stores the binary on ACS (Akord Cloud Storage) and does not trigger blockchain transaction. Cloud storage balance is consumed.
Example response:
Last updated
Was this helpful?