Is there a way to allow users to execute a custom R function with personalized arguments through a web-based platform? Additionally, the option to upload local files for use should be available.
Prior attempts to achieve this goal using OpenCPU were successful. The user's code is encapsulated within an ocpu.Snippet
and sent alongside specified arguments args
during the following call:
ocpu.call(
'do.call',
{
'what': snippet,
'args': args
},
session => /* processing of return value and console output */
);
This method has proven effective with various argument types thus far.
However, upon testing file uploads, some limitations have been revealed:
- The modified JavaScript wrapper (without alerts) can only recognize files at the topmost level, causing issues when attempting to pass a file object within an existing set of arguments (
args = { file: File }
). In contrast, directly callingocpu.call('read.csv', args, ...)
successfully triggers detection offile: File
. - It appears that OpenCPU mandates file uploads in
multipart/form-data
format, rendering nested file structures incompatible with this requirement. - One potential alternative involves creating a custom R function that facilitates the incorporation of used files as primary arguments, enabling their seamless transfer to the designated function.
This dilemma prompts the search for a solution, particularly pertaining to the development of such a function and exploring alternative methods for remotely invoking a customized function while managing its arguments. Any suggestions on how to address this complexity would be greatly appreciated.