shapeways / node-shapeways Goto Github PK
View Code? Open in Web Editor NEWNode client for shapeways api
Node client for shapeways api
The string contents of error.data look like a json object, but it is actually unparsable.
I made an example of something similar I am trying to do here: awongh@5ecee61
The specific string I am seeing is:
"{"result":"failure","reason":"You attempted to upload the file \"example\" which has an unsupported or missing file extension. We currently only support STL, OBJ, X3D, Collada, VRML97, VRML2 and ZIP file formats. Please ensure that your files are of one of our supported formats with the correct file extensions. If you can't export to those formats, please see our tutorial \"<a href='\/tutorials\/converting-with-accutrans-3d'>Converting with AccuTrans<\/a>\"."}{"result":"failure","reason":"Model Upload Failed. (Reason: 100)"}"
Can error.data be a valid json parseable string?
Thanks.
Getting invalid signature when doing any POST calls (like addModel
), the error goes away when using PLAINTEXT
rather than HMAC-SHA1
I am consistenly getting a 401 oauth_signature_invalid when using the addModel function. Are you aware of any issue with the OAuth library?
I've noticed this has been an issue more than once, I've looked at other posts about it but it failed to help me solve it.
I'm using the http example in the node-shapeways module, however instead of the getApiInfo call, I'm using the addModel call. The getApiInfo call works fine, as well as other GET functions, but I get a signature error on POST requests or at least in this case, addModel function.
User @giles7777 suggested I should make sure oauth uses headers with Accept and Content-Type set to application/json, I've done that in client.js in the client constructor on line 49
this.connection = new oauth.OAuth(
this.url("/oauth1/request_token/"),
this.url("/oauth1/access_token/"),
this.consumerKey,
this.consumerSecret,
"1.0A",
this.authorizationCallback,
"HMAC-SHA1",
null,
{"Accept" : "application/json",
"Content-Type" : "application/json",
"Connection" : "close",
"User-Agent" : "Node authentication"
}
);
But that still didn't work, was still getting signature invalid error from oauth, I also tried switching to PLAINTEXT instead of HMAC-SHA1, but same results.
Could this problem be coming from the Shapeways API or the node module?
This is how I'm calling addModel, I am not encoding the file content because I know this module does that for me as I saw in the addModel function
var data = fs.readFileSync(modelFile);
var postData = {
hasRightsToModel: 1,
acceptTermsAndConditions: 1,
title: "Test",
description: "Just Testing",
fileName : "couch.obj",
file: data
};
client.addModel(postData, function(result){
res.writeHead(200, {"Content-Type": "application/json"});
res.end(JSON.stringify(result));
});
Is there anything wrong with the way I'm doing that? Please let me know how to solve this if you have any idea, thanks!
"If I may presume to make one suggestion going forward, it would be that you consider adding a streaming API for uploading the models themselves. For performance reasons, I think that this is absolutely essential, especially when you are consuming larger models produced by external processes or redirected from disk. Globbing an entire mesh into memory for each upload can quickly consume all of the limited heap available to a node process and cause server crashes. Streams also implement back pressure which optimally handles performance and routing problems for throttling. I half-heartedly tried to get something like this to work in the older SOAP api, but was unsuccessful mostly due to the undue hassle of inserting a stream into the middle of a SOAP request and the general crappiness of the current options for handling SOAP/XML in node. However with the current REST system, I believe that this should be much easier to implement and that it really ought to be exposed as the default method for uploading."
From @mikolalysenko via e-mail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.