
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 domain issue
Hello following another post I'm creating dedicated post according to my project ID: 67ffbd800010958ae104 I deployed for debug my React Native app in web, chrom...
- Appwrite DNS Record Invalid on 123reg
So I go to the project settings and add in my domain name. Then when I add the CNAME record to 123reg it says that ''Record data is invalid'' As seen in the s...
- Image preview error
cannot see the image preview ..please help me fix this issue
