
Hi @everyone, While uploading image on stage, I'm facing this error
TypeScript
type: 'storage_file_type_unsupported',
response: {
message: 'File extension not allowed',
code: 400,
type: 'storage_file_type_unsupported',
version: '1.6.0'
}
}
⨯ AppwriteException: File extension not allowed
at async $$ACTION_8 (./lib/actions/user.actions.ts:171:29)
digest: "940634400"
POST /dashboard 500 in 240ms
When i'm developing using this code
TypeScript
export const createPost = async (data: Post) => {
const { post_id, image_urls } = data;
const now = dayjs().toISOString();
const validPost = generateValidPostId(post_id);
try {
const { databases, storage } = await createAdminClient();
if (!image_urls || !Array.isArray(image_urls) || image_urls.length === 0) {
throw new Error("image_urls is not a valid array or is empty");
}
// const res = await fetch(image_urls[0]);
// const blobs = await res.blob();
const renamedFile = new File([image_urls[0]], `${validPost}`);
const createdFile = await storage.createFile(
postAttachementBucket,
ID.unique(),
renamedFile
);
console.log("File created:", createdFile);
const post = await databases.createDocument(db, postCollection, validPost, {
...data,
post_id: validPost,
created_at: now,
updated_at: now,
image_urls: createdFile.$id,
});
console.log("Post created:", post);
return parseStringify(post);
} catch (error) {
console.error("Error in createPost:", error);
throw error;
}
};
TL;DR
Error message indicates that the file extension is not allowed when trying to upload an image using NextJS 14. The issue might be due to the file's extension not being supported. The developer is attempting to upload an image file, but the code snippet provided needs to be reviewed to ensure that the file format is supported.Recommended threads
- Google sign in wont allow you to choose ...
Hi, this is still unsolved, Appwrite's SDK won't let you specify prompt=select_account param, so a user cannot signin with a desired account, in chrome is just ...
- Console ErrorAppwriteException: User (ro...
AppwriteException: User (role: guests) missing scope (account) at Client.eval (webpack-internal:///(app-pages-browser)/./node_modules/appwrite/dist/esm/sdk....
- AppwriteException: Project ID not found
I'm getting this error: `Error signing up: AppwriteException: Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project...
