bundlr.uploadFile(fileName, tags)
Uploads a file.
Parameters
-fileName
: Name of the file to upload - tags
:
Optional metatags
Returns
-response
: A JSON object with the following values
response = {
id, // The transaction id of the upload
timestamp: // The timestamp of when the transaction was uploaded and verified
}
// Your file
const fileToUpload = "./myImage.png";
// Add a custom tag that tells the gateway how to serve this file to a browser
const tags = [{ name: "Content-Type", value: "image/png" }];
try {
const response = await bundlr.uploadFile(fileToUpload, tags);
console.log(`File uploaded ==> https://arweave.net/${response.id}`);
} catch (e) {
console.log("Error uploading file ", e);
}
ℹ️
The transaction id returned as part of the response is used to download the
data, simply create a URL with the format
https://arweave.net/[transaction-id].