Dear Keith, I don't know the best way but this work for us. It is used in cooperation with ACE editor (written in JS): <script type="text/javascript" charset="utf-8"> var hist_id = null; $(function() { var address = '${prefix}/history/current_history_json'; $.get(address, function(resp) { if (resp && resp.id) hist_id = resp.id; }); $('#save_btn').on('click', function() { var cont = ace.edit('editor').getValue(); # or any other data, you need to save in new file, here, the data are textual var dInputs = { dbkey: '?', file_type: 'auto', 'files_0|type': 'upload_dataset', 'files_0|space_to_tab': null, 'files_0|to_posix_lines': 'Yes' }; var formData = new FormData(); formData.append('tool_id', 'upload1'); formData.append('history_id', hist_id); formData.append('inputs', JSON.stringify(dInputs)); formData.append('files_0|file_data', new Blob([cont], {type: 'text/plain'}), $('#editor').attr('file-name')); $.ajax({ url: '${prefix}/api/tools', data: formData, processData: false, contentType: false, type: 'POST', success: function (resp) { # this part is there to refresh the history panel otherwise it seems not to turn green window.setTimeout(function() { window.parent.$('#history-refresh-button').trigger('click'); }, 3000); } }); }); }); </script> I hope it helps you. Best regards, Martin Demko Keith Suderman <suderman@cs.vassar.edu> wrote on Mon, 23 Apr 2018 15:38:19 -0400:
My Google-Fu is failing me...
We have a visualization plugin that can also serve as an editor to modify the data it is visualizing. What is the best way to save the data from the visualizer back to Galaxy?
I seem to recall reading (somewhere, sometime) that the REST API could not do this and the "best" solution is to invoke the upload tool to upload data into the current history. I have used the upload tool from the Python and Blend4J APIs, but I can not find a JavaScript example for invoking the upload tool.
So two questions:
1. Is the upload tool (still) the recommended way to put data into the current history via API calls? 2. How do I invoke the upload tool from JavaScript?
Thanks, Keith
---------------------- Keith Suderman Research Associate Department of Computer Science Vassar College, Poughkeepsie NY suderman@cs.vassar.edu