How to access the content of text file stored in files API

  Hi, I receive from the client side a base64-encoded string and I store it in a .txt file in the files api ,is there any way to get the content of this text file using javascript .

Thanks in advance.
var data=car.picture;
const FileURL=“https://backendlessappcontent.com/5FB0EA72-A363-4451-FFA5-A56F031D6600/C8502745-CB10-4F56-9FD5-3EFCE59F1926/files/testfolder”;
Backendless.Files.saveFile( ‘testfolder’, ‘car.txt’, data, true );
car.picture=FileURL+’/’+‘car.txt’;
Car.save(car);
return car;

Hi,

you can use atob function, please read more here about Base64 encoding & decoding in JS.

Regards,
Stanislaw

we have been trying for couple of days to solve this problem, unfortunately nothing worked. Regarding the solution you’ve mentioned above, we get “message”: atob is not defined"
we tried to import relevant library, still didn’t work. Mark Piller gave us the same solution aswell. My teammate has tried many approaches (Window, WindowBase64, scope) all of them gave “undefined” message, he even tried somehow to copy the content of atob function to the backendless code.
thank you for your time, we appreciate your quick responses and effort.

best regards,
PickApp team

Which environment do you use for your app? Is it browser, node or smth else?

we’re trying to do that in backendless functions. javascript API services

and we’re invoking the function through the browser

Hi,

If you’re trying to get ‘atob’ propery in your app’s BL/API SERVICES page, you can’t do it. Logic is invoked not in the browser side, so window doesn’t exist. Like it was said here

your task can be done, f.e., in NodeJS. Try to use Buffer class

Buffer.from(content, 'base64').toString('utf8');

Regards,
Igor

we’re aware of the difference between nodejs and frontend js now, websites are full of frontend js and this led us to confusion.
Thanks for helping.