[OutSystems Now] DeviceFeatures\SaveFile webblock: how to save file in a different directory?

[OutSystems Now] DeviceFeatures\SaveFile webblock: how to save file in a different directory?

  
Forge Component
(34)
Published on 24 Nov (14 days ago) by OutSystems
34 votes
Published on 24 Nov (14 days ago) by OutSystems
Hi,

When using DeviceFeatures\SaveFile webblock, if I include a directory path in the Filename input parameter (e.g. "outsystems-now-test/log.txt"), it won't work and I get an INVALID_MODIFICATION_ERR message, such as the one below:

   

Probably some error in trying to modify the device's filesystem (this is Android, by the way).
Any ideas on how to overcome this?
Will further digging into the Apache Cordova API be needed?

Thanks!
Hello Pedro.

The way that the SaveFile WebBlock is implemented won’t allow you to provide that kind of paths. It just expects the Filename. To achieve what you want you’ll have to change the SaveFile javascript to use more sophisticated logic. One example is using the resolveLocalFileSystemURL
 
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) { });
 
For more examples you’ll have to take a closer look at the Cordova File Plugin – Where To Store Files
 
Thanks