blitline-dev / simple_blitline_node Goto Github PK
View Code? Open in Web Editor NEWSimple wrapper for sending jobs to Blitline
Simple wrapper for sending jobs to Blitline
Javascript supports native Promise
API, so there's no need to require bluebird
.
Response for following example is always empty (never reached)
blitline.postJobs( function(response) { console.log(response); })
Although if I console log in following code, I see that request was executed successfully:
res
.on('data', function(chunk) {
return result.push(chunk.toString());
})
.on('end', function() {
console.log(result.join(''));
// when the response ends, send the response back to the callback
return resolve(JSON.parse(result.join('')));
});```
Since version 0.8 http.createClient is depreciated (no longer works) and produces an error. Rewrite for http.request is required.
This is what I have written instead. Do with as you please as it comes without warranty.
(function() {
var Blitline, http,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
http = require('http');
module.exports = Blitline = (function() {
function Blitline() {
this.postJobs = __bind(this.postJobs, this);
this.addJob = __bind(this.addJob, this);
}
Blitline.jobs = [];
Blitline.prototype.addJob = function(jobHash) {
this.jobs = this.jobs || [];
return this.jobs.push(jobHash);
};
Blitline.prototype.postJobs = function(callback) {
var body, options, req,
_this = this;
body = JSON.stringify({
"json": this.jobs
});
options = {
"host": "api.blitline.com",
"port": 80,
"path": "/job",
"method": "post",
"headers": {
'Content-Length': body.length,
'Content-Type': 'application/json'
}
};
req = http.request(options, function(res) {
var result;
result = [];
res.on("data", function(chunk) {
return result.push(chunk.toString());
});
res.resume();
return res.on("end", function() {
return callback(null, result.join());
});
});
req.on("error", function(e) {
console.log("ERROR:Blitline:ErrorHandler: ", e);
return callback(e, null);
});
req.write(null, body);
return req.end();
};
return Blitline;
})();
}).call(this);
works for me but i dont know if it is inline with your intent/its not well tested. Some modification/cleanup may be required. It returns the raw response not json(which could be changed with ease).
Written with node 0.8.20.
Regards
Adam
Not sure if this is a problem in this module or the service itself:
undefined:1
tp://s3.amazonaws.com/mybucket/user/1234/7a7DrON-sm.jpg"}],"job_id":,"3kgnMhrT
^
SyntaxError: Unexpected token ,
at Object.parse (native)
at IncomingMessage.<anonymous> (/Users/erikmadsen/Documents/Projects/Server/node_modules/simple_blitline_node/lib/blitline.js:43:32)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickDomainCallback (node.js:381:11)
I would suggest replacing the console.log line with this:
console.log(nodeutil.inspect(response, { depth:10, colors: true }));
And include a line at the top:
var nodeutil = require('util');
Otherwise, as is, you don't see the URL in the output. Instead you see this:
{ results: [ { images: [Object], job_id: '...' } ] }
with the word "[Object]".
Hi,
We have been using the pre-process move-original feature in order to store the original image.
The source images are of various mime types, but we are attempting to save them all as .jpg
.
{
"application_id": "YOUR_APP_ID",
"src": "http://example.com/image.png",
"pre_process": {
"move_original": {
"azure_destination": {
"account_name": "account",
"shared_access_signature": "https://foo.blob.core.windows.net/sample/image.jpg"
}
}
}
}
This works fine when the source image is .jpg
, but fails for other types such as .png
or .gif
.
The error reported is
Image processing failed. Conversion between raster formats not supported. Please just output via job functions and save
or
Image processing failed. .gif -> .jpg conversion unsupported here
Incidentally, using a the no_op
function to store the original does work.
I would expect the move-original
feature to work the same.
Thanks.
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.