Skip to content

Instantly share code, notes, and snippets.

@gordonwoodhull
Created July 25, 2014 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gordonwoodhull/8bf3ccc607b4164c8f22 to your computer and use it in GitHub Desktop.
Save gordonwoodhull/8bf3ccc607b4164c8f22 to your computer and use it in GitHub Desktop.
anonymous upload example
# load the JS function that will register the ocaps
setup <- rcloud.install.js.module("upload_funcs",
rcloud.get.notebook.file("upload_funcs.js"), TRUE);
# create a structure of the ocaps needed for file upload
make.oc <- rcloud.support:::make.oc
file_upload = list(
create = make.oc(rcloud.upload.create.file),
write = make.oc(rcloud.upload.write.file),
close = make.oc(rcloud.upload.close.file),
upload_path = make.oc(rcloud.upload.path)
)
# and register them in window.upload_caps for use in the file selector below
setup$setup_upload_ocaps(file_upload);

<script type="text/javascript"> $("#filesel").change(function() { // this will send confirmations and errors to file upload pane // in edit mode or to the main output div in view mode // (or configure options.$upload_results) RCloud.UI.upload_with_alerts(false, {upload_ocaps: window.upload_ocaps, $file: $("#filesel")}); // or this form does not do any UI in itself, and takes a react // structure for overwrite confirmations, progress, etc. // will need to set up react or do force: true to do overwrites //RCloud.upload_files({force: true, $file:$('#filesel')}); /*upload_ocaps: window.upload_ocaps, files: $("#filesel")[0].files}); */ }); </script>
({
setup_upload_ocaps: function(ocaps, k) {
var paths = [["upload_path"],
["create"],
["write"],
["close"]];
window.upload_ocaps = RCloud.promisify_paths(ocaps, paths);
k();
return;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment