API Reference

Use the upload method to replicate an existing file to Sia Network.

const file = /* your file data */; // Your file input or Blob.
const filePath = "driveid_folder1id_folder2id"; // Location of your file
const replicateTo = { SIA: true };

try {
  const [uploadResult, error] = await sdk.dsns.upload({
    file,
    filePath,
    replicateTo
  });

  if (error) {
    console.error('Error replicating file:', error);
  } else {
    console.log('File replicated successfully:', uploadResult);
  }
} catch (error) {
  console.error('An unexpected error occurred while uploading the file:', error.message);
}

Params

  • file (formData): The file data to be uploaded.
  • filePath (string): Location of your file (ex. driveid/folder1id/folder2id)
  • replicateTo (object): An object containing the desired DSN to replicate to.

Required API Key Permission

  • Upload File