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
- `type 'Null' is not a subtype of type 'b...
When creating a new file using Appwrite Flutter SDK, the file is successfully created on the server, but the client throws the following exception: ``` type ...
- Console: Query on attribute has greater ...
I noticed an issue when one of my tables reached over ~800 rows. That table is relational to my users table Within the console I am able to view the table with ...
- Appwrite 1.8.1 - Traefik Returns 404 Due...
Problem: Fresh Appwrite 1.8.1 installation returns 404 on all requests. Traefik can't communicate with Docker daemon. Error: Error response from daemon: client ...