Hi,
I want to upload a file - zip - to my server. File is created in ruby context.
Using javascript I want to upload the file .
How can I pass the file object reference to js ?
Passing the file path won’t work as js will not be able to load file in memory from the path.
What do you want to pass, a reference to the file (such as a path) or the actual file content? Is the “server” running locally as a part of a plugin or is it an actual remote (web) server? Will the user view a web page in a web/html dialog or is the communication taking place “under the hood” of the plugin with the user interacting to something else?
I want to upload a file using javascript to remote server.
File is nothing but the exported and zipped version of the model.
Plugin UI is shown using the HtmlDialog. Once user selects upload button I prepare the zip and wants to upload it through javascript. But javascript needs file reference to the zip .
How can I pass the reference to javascript from ruby for the zip file ?
If the user is selected the file themselves, use a <input type=“file” /> element. Otherwise I wouldn’t do the upload through the web/HTML dialog at all. I don’t think Javascript can be used for this.
I have tried with ruby. The problem with ruby is that it hangs Sketchup. Sketchup goes to not responding state.
That is why I was looking for a way to transfer through javascript.
Let me try this.
I am using Amazon aws SDK to upload. Need to check if there is an API which sends the file in chunks so that I can use UI.start_timer to make it async.
As far I remember Threads do not work in embedded ruby.
Even I tried some basic tests on threads in Sketchup console. It was not working as expected.
If you have working examples please share.
Thomas might have written a method that on WIndows can cause the SketchUp application to peek it’s window messages at an interval that prevents the Not Responding state.
Check his TT_Lib2 code at BitBucket. https://bitbucket.org/thomthom/
When you call .join it will cause the main thread to wait for your thread to complete before it continues.
Additionally, Ruby threads doesn’t work well inside SketchUp. For an unknown reason they don’t appear to do work unless the main thread is busy. On top of that the Ruby API can only be called from the main thread.