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
- function subdomain ssl certs
The generated subdomain isn't getting a valid ssl cert, I was wondering if appwrite automatically generates one or uses a wildcard for *.functions.domain.com? ...
- Searching by attribute "name" requires a...
I have a table "products" with a few columns I'm trying to search by, but I get this error: ```json { "message": "Searching by attribute \"name\" requires a...
- Issue with usage
I have a weird problem, my project on appwrite was using avarage 5-10k reads a day, it was okay, but suddenly last 7 days, reads are about 60k a day, the code h...