API Reference

The getUrl method retrieves a temporary blob URL for downloading a file (encrypted or not). It allows you to specify a password for decryption, track download progress, and initiate the download using the obtained blob URL.

  try {
    const id = "file_id_here"; // The ID of the file to retrieve.
    const password = "file_password_here"; // Optional: Add if the file is encrypted.
    const abortSignal = null; // Optional: Pass an abort signal to cancel the operation.
  
    const [data, error] = await sdk.file.getURL({
      id,
      password,
      signal: abortSignal,
      setProgress: (progress) => {
        console.log(`Download Progress: ${progress}%`);
      },
    });
  
    // Check for success
    if (error) {
      console.error("Failed to retrieve Blob URL:", error);
    } else {
      console.log("Temporary Blob URL:", data);
    }
  } catch (error) {
    console.error("An unexpected error occurred:", error.message);
  }

Params

  • id (string): The ID of the file.
  • password (string, optional): An optional password to access the file. You can get the password using this method: https://delta-storage.readme.io/reference/readfile
  • signal (optional): An abort signal to cancel the operation.
  • setProgress (optional): A callback function to track the download progress.