Roadblock: How to write files outside of the iOS secure sandbox?

I’m working on my second AppGyver app and have hit a roadblock.

The purpose of the app is to …

  1. enter customer data
  2. send customer data to a rendering service and return a merged pdf or doc file
  3. save the file or send to another app for further editing/printing

Steps 1 and 2 are complete.

For step 2 I’m using an API at to render and return a pdf file that can be viewed via the preview PDF function.

I’ve gotten to step 3 and have hit a roadblock.

I’ve only been able to get the write file function store the file within the app using the variable: systemVars.fileSystem.directories.document

Also, the preview PDF function seems a little buggy. There’s no obvious way to close the preview screen. Took a while to figure out that you need to swipe down to close it. And there’s no option to print or send the output to another app.

Looking for some ideas on what to do next …

  1. Is there a way to write the file to an external source outside of the secure iOS app sandbox?

  2. Is there a way to send the file to another app on the iPhone or iPad (to the Files app or MS Word app)?

  3. Is there a way to save the file when running via the Preview app within a browser and save the file to a local drive?

  4. Does anyone know of a pdf/doc rendering service that stores the app within their service. I can then get the rendered file outside of the app.

  5. Another option could be to use Zapier and send the completed doc via an HTTP request.

Has anybody had any success with this or suggestions on how to do the above?

Thanks in advance :slight_smile:

Still struggling with this roadblock.

I tried option 5 (connect via Zapier). Created a REST API (webhook) zap to send the pdf file over to Dropbox but it looks like Dropbox only writes text files and I think it needs to written at Base64.

Does anyone have any ideas?

Sorry for the long delay!

For 1. and 2. AFAIK not at the moment – invoking the iOS Save file dialog requires access to a new API that’s not yet implemented, and the Open share dialog currently only supports text. Feel free to make a feature request to though!

For 3. You can use

For 4. no suggestions unfortunately, but 5. seems like a solid option!

You can also convert the file to Base64 before the POST to Zapier with

Thanks @Harri_Sarsa

I was able to get option 3 working via web using the download-base64-test-as-file-web-only function.

Playing around with option 5 (send to Zapier and load to Dropbox) and tested your suggestion to covert file to base64 first and have hit a snag.

I have a text string from the rendering service and not sure how to get it to the convert-file-to-base64 function since the convert-file-to-base64 is expecting a file path (not a text string).

I tried write-file first and then using the covert-file-to-base64 but it doesn’t seem to work. When writing the file I tested encoding for utf8 and base64 (ascii throws an error).

Is there a way to convert the text string to base64 without writing the file? Perhaps in javascript?

… Ron