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
- Local appwrite run functions --user-id n...
Hi, I'm running into an issue when testing Appwrite functions locally with user impersonation. I'm using a self-hosted Appwrite instance and running functions ...
- Selfhosted Github App installation
I've followed this guide: https://appwrite.io/docs/advanced/self-hosting/configuration/version-control to connect GitHub to my self-hosted Appwrite instance (1....
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...