
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
- Creating a relationship with nested obje...
{ "data": { "name": "DiDi", "type": "Software Development", "userJobs": [{ "$id": "68cbf1e2003612fb13ca", "j...
- Realtime integration with SSR auth
Hey, I have a nextjs website with SSR auth, works great. I use a session client for user verification and an admin client with API key. Both is used with node-...
- Looking for Partner
I'm looking for a partner for long-term collaboration. Of course, you'll get paid for it. If you are interested, please send a DM to me
