Back

Storage download request hanging.

  • 0
  • Self Hosted
  • Storage
xmaniaxz
26 Feb, 2025, 14:03

As the title says. I have a large file (3GB) that I would like to make downloadable. However i am running into the issue where for some reason code that executes just stays hanging. I have tried a work around by using a direct URL but it still hangs.

Code:

TypeScript
try{
  console.log("Got Request")
  const client = await CreateAdminClient();
  const storage = new Storage(client);
  const ID = (await storage.listFiles(bucketID,[],filename)).files[0].$id;
  console.log("Got File")
  // HANGS HERE
  const response = `https://${process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT}}/storage/buckets/${bucketID}/files/${ID}/download?project=${process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID}`
  console.log(response);
  //const response = await storage.getFile(bucketID,ID);
  console.log("Got Download Link")
  return {code:200,message:response};
  }
  catch(error){
    return {code:404,message:error};
  }
TL;DR
Developers are experiencing hanging issues when trying to download a large 3GB file using Appwrite's storage feature. It seems that the code gets stuck after logging "Got File." The problem may be related to serving the entire file at once instead of in chunks. A potential solution could be to check if the issue persists when using chunk downloads.
xmaniaxz
26 Feb, 2025, 14:05

Also. if i run the response command, it only downloads a single chunk

ideclon
26 Feb, 2025, 14:29

// HANGS HERE After logging "Got File"?

xmaniaxz
26 Feb, 2025, 14:31

Yeah. i did some more testing and i think its because it is trying to server the entire file at once instead of in chunks.

ideclon
26 Feb, 2025, 14:32

You're not actually downloading anything in the code fragment, as far as I can see

xmaniaxz
26 Feb, 2025, 14:32

true, i am getting the download link and then sending it to my front end.

xmaniaxz
26 Feb, 2025, 14:32
TypeScript
const handleDownload = async (filename: string, index: number) => {
    setDisabledButtons((prev) => [...prev, index]);
    console.log("Button has been pressed. preparing download")
    const response = await GetDownloadLink(bucketID,filename);
    if(response.code === 200){
      const blob = new Blob([response.message as BlobPart]);
      const url = window.URL.createObjectURL(blob);
      const a = document.createElement("a");
      a.href = url;
      a.download = filename;
      document.body.appendChild(a);
      a.click();
      a.remove();
      window.URL.revokeObjectURL(url);
    }
    setTimeout(() => {
      setDisabledButtons((prev) => prev.filter((i) => i !== index));
    }, 5000); // Re-enable the button after 5 seconds
  };
ideclon
26 Feb, 2025, 14:33

Is this in a Function? Otherwise, this doesn't look like an Appwrite issue

xmaniaxz
26 Feb, 2025, 14:34

It definitely is an appwrite issue. It seems like it does eventually download but it takes like 10 minutes until i get a response from await storage.getFile(bucketID,ID)

ideclon
26 Feb, 2025, 14:35

I don't see a call to storage.getFile() anywhere in your code fragment

ideclon
26 Feb, 2025, 14:35

Well, there is, but it's commented out

xmaniaxz
26 Feb, 2025, 14:36

its the part that is commented out, i check with just a direct link and with the SDK function. The direct link only download a 15kb file and the sdk function takes 10 minutes until it returns

ideclon
26 Feb, 2025, 14:39

Is it possible there was an issue with the upload?

xmaniaxz
26 Feb, 2025, 14:40

no, because i go to my storage and download from there it does work without issue. I think it might have to do with the fact that the file is 3GB.

xmaniaxz
26 Feb, 2025, 14:42
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more