UI Builder Read URL text file

Hi, I need to process a text file outside Backendless.
I’m working with “Convertio API” for OCR of an ID to take from picture all the data.

I have the url and is a txt file.
https://s161.convertio.me/p/WekaQuYpMOUTxi5rYZwoRg/d803b29d3f7d55d8720e2c49c3fdbd17/roberto_legal_id.txt

How can be read to a put inside a variable to work with “Text” functions?

I found this link How to Download Files From Backendless File Hosting | Backendless but I can’t understand how to build it in UI Builder.

Thanks, Mario

Hello @Mario_Ghersi ,

Here is an example. Suppose you have a button, goto logic section

Create on click event and create variable

use network API block to download file content

Dear Sergey

Thanks for your help maybe you can help me with the error when I try to GET the file.

https://artemy.convertio.me/p/m0NHcGsJ8oCIvJsVxzhgnQ/d803b29d3f7d55d8720e2c49c3fdbd17/roberto_legal_id.ocr.csv

This is a link to reproduce the error in your great example.

Thanks, Mario

The browser blocks the request, because the server that you are trying get file from do not add Access-Control-Allow-Orign header.
As work around you can create Backendless Codeless service which will get the file content and return its value. In this case you will not get the error because file will be got not by browser, but by the node process

Dear Sergey

Can you translate to an example because I can’t follow you with the solution.

Thanks, Mario

Here’s a tutorial for creating an API service: Creating API Service - Backendless Codeless Development Guide

Thanks the example to getServerTime works perfect but it’s far away for me to understand how to download the file from the Convertio API. I sent the file using POST no problem but to GET I’m dealing with Access-Control-Allow-Orign.

This is the file to read and extract the info: https://artemy.convertio.me/p/m0NHcGsJ8oCIvJsVxzhgnQ/d803b29d3f7d55d8720e2c49c3fdbd17/roberto_legal_id.ocr.csv

Thanks, Mario

You can use the instructions shown above to download file contents. What you need to do differently is use those instructions in an API service.

This works perfect for a file inside the Backendless platform but for a file I need to read at the Convertio platform give me the Access-Control-Allow-Orign error.

Are you using this logic in an API service or a UI Builder page?

In the UI Builder because everything of the logic is inside Backendless.

I’m taking a photo of a legal ID and need to add in my database. So simple but with the GET file problem to solve.

Well, a workaround had been described here.

Yes so simple for you guys but I don’t have a clue what does it means for me… sorry.

Have you created an API service per the instructions I shared?

I don’t know how to write or build the service.
Also I try the “Copy File/Directory” but it’s not working for file in other server.

The screenshot you shared shows that when you call that URL in your codeless logic, their server returns the 403 Forbidden error code.

https://artemy.convertio.me/p/m0NHcGsJ8oCIvJsVxzhgnQ/d803b29d3f7d55d8720e2c49c3fdbd17/roberto_legal_id.ocr.csv

The file is there. If I paste the link in a browser allow me to download but how to download programmatically inside Backendless? That’s the question to solve.

Doesn’t work here from a browser, getting the same thing as in your logic:

https://artemy.convertio.me/p/m0NHcGsJ8oCIvJsVxzhgnQ/d803b29d3f7d55d8720e2c49c3fdbd17/roberto_legal_id.ocr.csv

When I click at the link open the window to download. That’s maybe give you a clue how to solve it?