hi, today i started using the appwrite, it is super simple but one think that got me stuck for the past 3 hours is not being able to uplad a image to a bucket, here is my code and i would explain what i want to acheve:
+PAGE.SVELTE CODE
<form use:enhance action="?/postskin" method="POST" enctype="multipart/form-data">
<input type="text" placeholder="naslov" name="title" />
<input type="file" name="image" accept="image/*" required />
<button><Plus /> POST SKIN</button>
</form>
+PAGE.SERVER.JS CODE
import { Client, ID, Storage } from 'appwrite';
export const actions = {
postskin: async ({ request }) => {
const data = await request.formData();
const image = data.get('image');
console.log(image);
console.log(image.type);
const client = new Client().setEndpoint('https://cloud.appwrite.io/v1').setProject('xxxxxxxxx');
const storage = new Storage(client);
try {
const result = await storage.createFile('xxxxxxxx', ID.unique(), image);
console.log(result);
return { success: 'Image uploaded successfully' };
} catch (error) {
console.error('Error uploading file:', error);
return { error: 'Failed to upload image' };
}
}
};
so i want my image to get upladed to bucket what i did: made sure that my id-s are correct, setuped the permisions to any with everything checked
what i get:
File {
size: 2138,
type: 'image/png',
name: 's.png',
lastModified: 1743171671561
}
image/png
Error uploading file: TypeError: source.on is not a function
if someone can explain to me what i did wrong or what should i do it would be highly apreciated
sorry for bad english
Recommended threads
- Custom API domain is unreachable
Earlier my custom api domain was working fine. Now it seems to be offline without a trace a few hours later. I didn't change anything, all the relevant DNS reco...
- "Invalid console fingerprint" when unpau...
I've tried logging out and logging back in, still can't figure out why this is happening.
- HTTP Error 500 ''
Hello to everyone, I'm a Flutter developer and actually I'm developing an app using Appwrite.. during my tests and also massive ones I've noticed something we...