Back

[SOLVED] Rest API upload File as a Blob or fromData in nodejs

  • 0
  • Functions
Luky
27 Aug, 2023, 16:50

Hey ! Hope you are doing well.

I have created a CSV as a string inside an appwrite function. Unfortunately The File class not being present on nodeJs prevents me from creating a File from my Blob and uploading it to the storage with the SDK.

(I have tried to implement a pseudo File class by adding name and type to the Blob. But when testing I get accessing .pipe error on undefined.)

Is there a way to achieve the desired result? Maybe via the rest API using formData ? The doc says File type but does it accept formData instead?

I am not at home now so I can't really test, But maybe someone has already encountered the same issue.Or have an idea for my next try.

Thanks for reading!

TL;DR
User is looking for a solution to upload a file as a Blob or formData in nodejs. They mentioned trying to implement a pseudo File class but ran into an error. They are wondering if the REST API accepts formData instead of the File type. Someone suggests using the InputFile class for deno and node. The user thanks them for the hint and asks for a link for the inputFile class. No solution is mentioned in the thread.
Luky
27 Aug, 2023, 17:01

Deno seems to have File class support.

Drake
27 Aug, 2023, 17:03

For deno and node, you should be using the InputFile class

Luky
27 Aug, 2023, 17:09

Thanks for the hint! I can't find inputFile class on the web for Js, (Only for dart) Do you have a Link please 🥺?

Drake
27 Aug, 2023, 17:43

Didn't you say you're using deno/node?

Luky
27 Aug, 2023, 17:54

Yes I use deno or node but I can't find any references of this class on Google.

Drake
27 Aug, 2023, 17:55

Would you please make sure you're using the node or deno sdk rather than web?

Luky
27 Aug, 2023, 17:56

Oh sry I was thinking this was a native JavaScript Class. I didn't even try to use the appwrite SDK 😵

Luky
27 Aug, 2023, 17:56

Thanks

Drake
27 Aug, 2023, 17:57

All good now?

Luky
27 Aug, 2023, 17:58

I can't test it for now but yeah it should be good. Thanks for your help!

Luky
27 Aug, 2023, 18:00

This is exactly what I was looking for

Drake
27 Aug, 2023, 18:00

[SOLVED] Rest API upload File as a Blob or fromData in nodejs

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more