I’m want to read the content of a file on Backendless file storage from within my JS code of my own Backendless service.
In the documentation (https://backendless.com/docs/js/files_overview.html) I just find the File Download REST API. Isn’t there a JavaScript API available for reading files (like, for instance, for removing files)?
Regards,
Hello @Klaas_Klever
To read the contents of the file, we only have the REST API for now:
https://backendless.com/docs/js/files_file_download.html
As a workaround, I can suggest that you create a method in the business logic that will return the contents of the file. And to call this method with JS-SDK.
However, I will discuss with the team to add such a feature through the SDK
File deletion documentation:
https://backendless.com/docs/js/files_file_deletion.html
Regards,
Inna
Hello @Klaas_Klever
In addition, I can propose to use our Backendless.Request library which is already placed in the JS-SDK.
const content = await Backendless.Request.get(YOUR_FILE_URL)
Regards, Vlad
Thanks! I will try both methods!
Regards
Hi @vladimir-upirov ,
I’m using the Backendless.Request lib now for reading an image file. I want to process this image further with external image processing libs. I have a hard time to convert the string result format of Backendless.Request.get
into something meaningful for these libs. Are there options to read in file content with other binary formats (e.g., Buffer, or Uint8Array)?
Regards,
try this one:
const buffer = await Backendless.Request.get(YOUR_FILE_URL).setEncoding(null)