-
Notifications
You must be signed in to change notification settings - Fork 4.4k
🐛 Bug Report: Can't createFile via n8n flow #3313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello there 👋 The problem is most likely related to the chunk uploading mechanism kicking in with direct HTTP communication (not using our SDKs to manage it). First, let's get details about the error. After getting the 500 error, please run the following command on a device where your Appwrite backend is installed: It would also be really valuable to know the exact CURL command you are using, and/or have the file you are trying to upload. These will allow us to reproduce the problem, and easily investigate underlying issues. |
Hi dear Meldiron At first: |
Based on this screenshot, it doesn't seem like the request format is correct. The content type should be Could you perhaps share your code? |
@stnguyen90 In fact I'm low coder person. After your advice I correct some options but I want to know what 8the correct format that I should send to my appwrite server. I also attached my new error from my docker compose logs.
|
It looks your sending "data" string for the file rather than sending the actual file. Maybe this will give you some insight into sending file data: https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/2 Otherwise, things look fine on the Appwrite side. |
Ah sounds like it's unsupported by n8n. Someone did create an Appwrite package for n8n but it doesn't look like it supports file uploads yet. Perhaps you can submit a feature request. |
Hey there 👋 As @stnguyen90 suggested, this is not natively supported by n8n. But there is a way! 😎 We can use Functions node to do this: In there, we will need to use NODE_FUNCTION_ALLOW_EXTERNAL=request-promise-native Whith that ready, enter following code into your function node: const request = require('request-promise-native');
const binaryData = items[0].binary.data;
try {
const data = await request({
uri: "[YOUR_ENDPOINT]/v1/storage/buckets/[YOUR_BUCKET_ID]/files",
method: "POST",
headers: {
'content-type': 'multipart/form-data',
'x-appwrite-key': '[YOUR_API_KEY]',
'x-appwrite-project': '[YOUR_PROJECT_ID]'
},
formData: {
file: {
value: Buffer.from(binaryData.data, 'base64'),
options: {
filename: binaryData.fileName,
contentType: binaryData.mimeType,
},
},
fileId: 'unique()'
},
});
} catch(err) {
return {ok: false, err: err};
}
return {ok:true};
With that, make sure you have a In the end, you should see a successful execution and a file uploaded to your Appwrite Bucket: I am attaching the whole workflow as a file. If you use it, make sure to replace all |
@theMeysam have you had a chance to test @Meldiron's suggestion? Is there anything else you need or can this be closed? |
Closing as no further action required. |
Thank you @Meldiron |
👟 Reproduction steps
When I try to add file to my appwrite storage by "create file" via API (Curl) it show bellow error:
{ "status": "rejected", "reason": { "message": "500 - {"message":"Server Error","code":500,"type":"general_unknown","version":"0.14.2"}", "name": "Error", "stack": "Error: Request failed with status code 500 at createError REDACTED" } }
👍 Expected behavior
It should add my image to storage
👎 Actual Behavior
ERROR: UNKNOWN ERROR - check the detailed error for more information
Server Error
🎲 Appwrite version
Version 0.14.x
💻 Operating system
Linux
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: