
hi everybody, I want to use Event for my file uploads. I want to save file data in the specific collection by adding files into the specific bucket. would you make an example of what I should do? I would appreciate any help to understand.

IIUC, you’re asking what the correct Event would be to trigger on file upload to a specific bucket.
I think it should be buckets.[BUCKET_ID].files.*

no i want file parameters i dont know what to write in function file. I use nodejs

Not sure what you mean by “file parameters”?

like size, name, type

Ah. I’m not 100% sure, but I’d check in req

I didn't find:(

May I ask one more question... is there any way to get file from form part in appwrite function? I want to get the file and add to storage in my function. but it says: Cannot read property 'pipe' of undefined

So you want to POST the files directly to a Function, then push to Storage from there?

Will try to have a look a bit later

sorry to answer late. thanks a lot for your response.

No I want to create a function and set the event to that. whenever I upload the file into the bucket, function triggers.

in that function, I get the file parameters (like size, name, ...) and create a document in my file_detail collection.

but the problem is that I cant find the data about the file that make the function run. there were hints like req. payload, ... but none of them work.

createFile
returns a File
object with the file metadata: https://appwrite.io/docs/references/1.4.x/server-nodejs/storage#createFile
getFile
does the same, you won't need an event to do that.
The workflow would be
- Upload file and wait the response to get metadata
- store the data in the collection you want

Those functions return the data to the code where you upload the Function. OP wants a Function to be triggered and needs to know the file details there.

I just checked, and I do indeed have a File object in req.body

You're right

The event should be: buckets.[BUCKET_ID].files.*.create
to be triggered just when the file is created, you should get a File object as well

Thank you very much :appwriteheart: @ideclon @Guille

[SOLVED] Event trigger
Recommended threads
- How to get event payload/source from fai...
Hi everyone, I'm currently working with Appwrite's database triggers, specifically for document creation events. I've encountered a potential issue and was h...
- Creating a custom function ID in the con...
Console Version 1.8.0 Google chrome Version 139.0.7258.66 (Official Build) (64-bit)
- Function stuck and has exceeded timeout
I have a function, or more specifically, an execution that has been running for 20+ minutes. It still says "processing". I have a timeout of 6 minutes for that...
