radumg / DynaWeb

DynaWeb is a Dynamo package providing support for interaction with the interwebz in general and with REST APIs in particular.
https://radumg.github.io/DynaWeb/
GNU Affero General Public License v3.0
43 stars 15 forks source link

Upload .rvt file ( PUT method) #11

Closed violacambie closed 7 years ago

violacambie commented 7 years ago

Expected Behavior

I would want to upload a .rvt file on a bucket hosted online.

Actual Behavior

I'm using PUT method. I can add Headers and Parameters to the URL but I'm not sure how upload the Revit file.

Steps to Reproduce the Problem

The WebRequest.AddBody doesn't let me specify the type ( "binary") of the model: any suggestion?

Specifications

- Dynamo : 1.3
radumg commented 7 years ago

Hey @violacambie , thanks for writing this up!

As a first few suggestions :

dynaweb add file

Also, could you let us know which service you're using, might help troubleshooting if we're able to look at their documentation and the DYN file. I assume you're trying to upload to a bucket on either AWS S3 or Azure (blob storage) ?

violacambie commented 7 years ago

Thanks for the replay!

yes I have tried the "WebRequest.AddFile" but I'm not sure the string should I use for a Revit model as "contentType": application/rvt? .rvt? application/octet-stream? binary?

Please have a look at the screenshot. With Postman I can simply upload a file as binary postman

I'm uploading the models in a bucket on the Autodesk Platforme ( Forge ) and I'm not sure wich type of storage is.

radumg commented 7 years ago

Hey Viola @violacambie , First off, thanks a lot for posting the Postman screenshot, helped a lot to know what works there and saved quite a few steps!

Identify issue

I signed up to a trial for Forge to test this out, was really curious how to get it working, here's what I found :

forge multi-part

Fix

So, I added another node to the package called WebRequest.AddFileAsBytes which adds the file as raw bytes to the request body.

forge add file new node

Package update

I'm releasing the updated, beta version of this on the Dynamo package manager tonight, search for DynaWeb, it will include this new node.

Sample

I've uploaded the entire DYN workflow in the samples folder, have a look at sample 7.

forge add file

Please try it all out and let me know how you get on 🤓

violacambie commented 7 years ago

Hey Radu@radumg

thanks for the updated version. The WebRequest.AddFileAsBytes works good!

However the WebRequest.SetMethod looks like is not working properly method

I have solved this issues thanks your new Execute.PUT ! method v2

Plus the Content-Type works both with "application/octet-stream" and "application/x-www-form-urlencoded": should I prefer just one of those?

radumg commented 7 years ago

Thanks for the feedback!

I had the same issue as your first screenshot - SetMethod is working, but the Request object is not being updated due to some Dynamo caching, which means it's still using the old token/request etc. Disconnecting the nodes, closing the file and re-opening should do the trick - i'm looking into ways of forcing it to update each time.

Re: the Content-Type, if both work, then the Forge platform isn't enforcing/using that, so it should also work without :grin: