Hi !
Calling getFlieView form the node sdk give a buffer containing the full text of the file instead of URL.href ?
const csvFile = await sdk.InputFile.fromPlainText(csvString, `batch_${batchId}.csv`);
const storageReponse = await storage.createFile("batch_cards_csv", batchId, csvFile);
const fileView = await storage.getFileView("batch_cards_csv", storageReponse.$id);
// Debugging
console.log("type", typeof fileView);
console.log("fileview Object", fileView);
console.log("fileview", fileView.toString());
console.log("href", fileView.href);
log output:
type object
fileview Object {"type":"Buffer","data":[49,44,104,116,116,112,115,58,47,47,108,11 ...
fileview 1,https://localhost:5173/card/nwbEC
2,https://localhost:5173/card/RSugw
3,https://localhost:5173/card/60Sm8
4,https://localhost:5173/card/vPf73...
Is there another way to get the href or i am missing something ?
PS: The file is correctly created and i can get the url in the appwrite UI. But not in the sdk.
Yes, this is expected. The url to the file is the path in the docs: https://appwrite.io/docs/server/storage?sdk=nodejs-default#storageGetFileView
Why do you need the url?
Yeah this work too. I need the url to make the client download the file automatically. If there is another way than using an hidden link and click() it would be better than this solution. I got it working by getting the link using the web-sdk :
const storageResponse = await storage.getFileDownload("batch_cards_csv", batchId);
const link = await createClientLink(storageResponse.href);
I download the file via xhr and then use
const link = (window.URL ? window.URL : window.webkitURL).createObjectURL(blob);
setDownloadLink(link);
set the link to an hidden link
<a ref={downloadLinkRef} href={downloadLink} download={`batch.csv`} style={{ display: "none" }}></a>
then click on it
downloadLinkRef.current.click();
So the user doesn't leave the current page.
Yes, this is the correct way to do it client side
Ok thanks for your reactivity !
Recommended threads
- TablesDB can't be used in Appwrite Funct...
I have written a function (DART) and it won't deploy. Here is what I get : 2026-03-14T17:09:41.459693680Z Compiling ... 2026-03-14T17:09:42.915619217Z ../build...
- 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 ...
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...