#[SOLVED] Event trigger

20 messages · Page 1 of 1 (latest)

torn crown
#

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.

rotund agate
torn crown
#

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

rotund agate
torn crown
#

like size, name, type

rotund agate
torn crown
#

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

rotund agate
rotund agate
torn crown
#

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.

charred slate
#

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

  1. Upload file and wait the response to get metadata
  2. store the data in the collection you want

The Storage service allows you to manage your project files. Using the Storage service, you can upload, view, download, and query all your project files.

Files are managed using buckets. Storage buckets are similar to Collections we have in our Databases service. The difference is, buckets also provide more power to ...

rotund agate
rotund agate
charred slate
#

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

torn crown
#

Thank you very much appwriteheart @rotund agate @charred slate