Upload file from HTTP Response

Hi,
I am using PDF Generator API to create some more advanced PDF files than what is supported by the native PDF generator in Ragic.

I make the request via util.getURL() method and everything works.
Now I need to take the response which can be either a base 64 file or a URL to the file generated (I can choose) and the put it in the field of the sheet.

Is it possible to do this at all in the installed sheet scope javascript?
Or I have to make the web service put the file in ragic via API instead?

Hi,

You can use a variable to receive the return value from util.getURL(). If it’s a URL, you can then use util.downloadFile(URL) to download the file into the “upload” folder of the database. This method will return the full file name, and you can then use entry.setFieldValue(fileName) to fill in the file field with this file name.

1 Like

Great stuff!

so var b = util.downloadFile(URL) will save the filename to b ?
Never figured out how that worked

That’s right! util.downloadFile will return a full file name, and once the file field receives this file name, it will bind the file in the upload folder that matches the name.

2 Likes