
how can i achive uploading a file to storage, using a url?
i attach a photo of an example i want to do, is that possible and any hints on how to do it?

You cant

There is no possible way??? Tried to fetch it and parse the buffer to it but did not work sadly

You should be able to upload via a buffer

async function uploadImage(
imageUrl,
imageName,
bucketId = process.env.IMAGES_BUCKET_ID
) {
try {
const imageResponse = await fetch(imageUrl);
if (!imageResponse.ok) {
throw new Error("Failed to fetch image from URL");
}
const arrayBuffer = await imageResponse.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const inputFile = sdk.InputFile.fromBuffer(buffer, imageName);
const result = await storage.createFile(bucketId, ID.unique(), inputFile);
return result;
} catch (error) {
console.error("Error uploading image:", error);
throw error;
}
}

Seems correct to me

Error uploading image: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number (3798243238)

Ah nvm see the error imageName should be an string

What sdk are you using?

Appwrite

const sdk = require("node-appwrite");

Maybe you can use InputFile.fromBlob(await imageResponse.blob())
Btw there's a new version of the node sdk

I tried updating lately and had loads of errors... So I just went back to the old one
Recommended threads
- [Node.js SDK] Bypass 2GB file limit?
Hello. Using either InputFile.fromPath or InputFile.fromBuffer throws this error: File size (2295467305) is greater than 2 GiB Bucket limit etc. is setup corre...
- Hi im using vvs studio to make a charact...
my game involves magic , leveling up aka "phase" max phase is 30 each 10 20 30 theres awakening 1 2 3 i want to make a character builder so that players can fig...
- Limit File Upload count?
Is there a way to limit the number of files a user can upload? I know there's a limit of file size but in my case I'd like to limit the user to only upload x am...
