Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload .rvt file ( PUT method) #11

Closed
violacambie opened this issue Aug 30, 2017 · 5 comments
Closed

Upload .rvt file ( PUT method) #11

violacambie opened this issue Aug 30, 2017 · 5 comments

Comments

@violacambie
Copy link

violacambie commented Aug 30, 2017

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
@violacambie violacambie changed the title I would want to upload a .rvt file on a bucket hosted online. I'm using PUT method. I can add Headers and Parameters to the URL but I'm not sure how upload the Revit file. The WebRequest.AddBody doesn't let me specify the type ( "binary")of the model: any suggestion? Upload .rvt file ( PUT method) Aug 30, 2017
@radumg
Copy link
Owner

radumg commented Aug 30, 2017

Hey @violacambie , thanks for writing this up!

As a first few suggestions :

  • have you tried using the WebRequest.AddFile node ? It was designed for this and should be able to handle uploading the file for you.
  • then, I would make the request a POST request, most web services accept creation of new records using that method.

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
Copy link
Author

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
Copy link
Owner

radumg commented Aug 30, 2017

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 :

  • Content-Type has to be application/octet-stream
  • the AddFile node was failing because it's defaulting to uploading in a multi-part/form way. this is equivalent to switching Postman body to form-data instead of binary
  • Forge doesn't accept multi-part data.

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 🤓

@radumg radumg closed this as completed Aug 30, 2017
@radumg radumg reopened this Aug 30, 2017
@radumg radumg modified the milestones: alpha-0.6 Use-cases, Use cases, alpha-0.6 Aug 30, 2017
@violacambie
Copy link
Author

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
Copy link
Owner

radumg commented Aug 31, 2017

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 😁

@radumg radumg closed this as completed Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants