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:
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};
}
Also. if i run the response command, it only downloads a single chunk
// HANGS HEREAfter logging "Got File"?
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.
You're not actually downloading anything in the code fragment, as far as I can see
true, i am getting the download link and then sending it to my front end.
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
};
Is this in a Function? Otherwise, this doesn't look like an Appwrite issue
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)
I don't see a call to storage.getFile() anywhere in your code fragment
Well, there is, but it's commented out
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
Is it possible there was an issue with the upload?
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.
Recommended threads
- Bulk API limitations in self-hosted serv...
Environment: Appwrite Selfhost SDK: node-appwrite 28.0 Calling `upsertRows` (also applies to `createRows`/`updateRows`/`deleteRows`) with more than 100 rows fa...
- Self Hosted GitHub connection not adding...
After upgrading to 1.9.6 i noticed that i cannot search for new repositories when trying to add new functions. I removed the existing github connection via Set...
- Unable to init function via cli
Hello! I have created a new self hosted instance of appwrite 1.9.6 and have connected to that insatnce with the cli 27.2.0 that was released a few hours ago. Wh...