Hello, I have encountered some issue with uploading an image to the bucket.
Usually, image upload is done from local point, however on some tutorial that was done recently, image url does point to the remote url, instead of local path to the image, and it does work there.
async function uploadImageToStorage(imageUrl: string) {
try {
const response = await fetch(imageUrl);
const blob = await response.blob();
const fileObj = {
name: imageUrl.split("/").pop() || `file-${Date.now()}.jpg`,
type: blob.type,
size: blob.size,
uri: imageUrl,
};
const file = await storage.createFile({
bucketId: appwriteConfig.bucketId,
fileId: ID.unique(),
file: fileObj,
});
return storage.getFileViewURL(appwriteConfig.bucketId, file.$id);
} catch (error) {
console.log("Returned an error:", error);
}
}
Here is sample data (sorry if included image url). So it does not pass the point to create a file, as uri is remote.
{
name: "Classic Cheeseburger",
description: "Beef patty, cheese, lettuce, tomato",
image_url:
"https://static.vecteezy.com/system/resources/previews/044/844/600/large_2x/homemade-fresh-tasty-burger-with-meat-and-cheese-classic-cheese-burger-and-vegetable-ai-generated-free-png.png",
price: 25.99,
rating: 4.5,
calories: 550,
protein: 25,
category_name: "Burgers",
customizations: ["Extra Cheese", "Coke", "Fries", "Onions", "Bacon"],
},
for (const item of data.menu) {
const uploadedImage = await uploadImageToStorage(item.image_url);
Is there any flag/permission that I can add to obj that allows pull from remote url, so I don't need to use local images?
Recommended threads
- DB connection | Got timeout reading comm...
When looking at the logs of `appwrite-mariadb` I'm seeing a lot of: ``` 2026-04-09 7:37:28 10 [Warning] Aborted connection 10 to db: 'appwrite' user: 'appwrit...
- Invalid document structure: Unknown attr...
Environment: Dart version: 3.5.1 dart_appwrite: 13.0.0 I’ve already created the database structure using a Dart function. I can create data records using cloud...
- android platform invaild origina
It happened today suddenly. Our app says invalid origin. And appwrite cloud says every time we tried to add the app to it: "param platformId" is not optional.