Giter Club home page Giter Club logo

simple_blitline_node's People

Contributors

ajwinkworth avatar blitline-dev avatar gmaclennan avatar jmalcolm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simple_blitline_node's Issues

Use native Promise?

Javascript supports native Promise API, so there's no need to require bluebird.

Return callback not working

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('')));
  });```

http.createClient is depreciated

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

Invalid JSON

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)

Small change to sample code

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]".

Pre-process move-original fails with "Conversion between raster formats not supported"

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.