kraken-io / kraken-node Goto Github PK
View Code? Open in Web Editor NEWOfficial Kraken.io module for Node.js
License: Other
Official Kraken.io module for Node.js
License: Other
We're experiencing 404 not found server errors when using this library, coming from Posts to https://api.kraken.io/v1/url
.
Using kraken 0.4.0 in the standard way:
//Create new Kraken instance and prepare optimisation options
const kraken = new Kraken();
const options = {resize, lossy, s3_store: {bucket, path}};
//Process file or URL
const result = await kraken.process(file, url, options);
Calling the URL directly from browser also results in a 404, but that's probably because it's not a POST.
Any thoughts though? Has been occurring frequently lately.
Hi,
I get this error while pushing to S3.
{ message: 'Error while pushing file to S3: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.',
success: false }
Please help me.
The S3 upload feature is great, but since we need to set cache-control headers on the files we upload, we still have to use the AWS-SDK to update the image after kraken has uploaded it. It would be great if this could be done in one step.
Hello,
I'm using the sandbox api and i have a problem since several days about the url returned by the api after an optimization, here is the object returned :
{ file_name: 'image.png',
original_size: 825114,
kraked_size: 165023,
saved_bytes: 660091,
kraked_url: 'undefinedimages/result.png',
success: true }
As you can see, there is a 'undefined' in the kraked_url, i think there might be a problem with the root domain of the url.
I use the node module 0.2.1
Thanks in advance!
Kraken-io accepting requests for new features in the next node client version. Feel free to ask any additional questions.
Main goal in the new version: make code flexible, use new JS features, easy to support and stable. No breaking changes are planned.
Hi All,
I am including one template within another template by using partials.
For ex,
{>"layouts/master" showMenu="false" /}
In master.dust, I am checking the 'showMenu' flag.
For ex,
{@eq key="{showMenu}" value="false"}
<< some coding part1>>
{:else}
<< some coding part2>>
{/eq}
If I run in development mode, it is fine(Meaning: It is coming to << some coding part1>>).
If I run in production mode, it is not fine(Meaning: It is coming to << some coding part2>>))
I am using
"dustjs-helpers": "1.7.3",
"dustjs-linkedin": "2.6.2",
"kraken-js": "2.0.1",
Node version :6.9.2
Please share your ideas in resolving this issue.
@matylla
I'm testing Kraken to optimize multiple images.
I tried it with images that work correctly using method kraken.upload but with others images, it doesn't work; the problem is that when kraken.upload is invoked and created request, no response, but I do not get any errors.
I tried too the sames images with method kraken.url then it works correctly.
My code:
var options = {
file: '/var/project/image-example.png',
wait: true,
lossy: true,
resize: {
width: maxWidth,
strategy: 'landscape'
}
};
var kraken = new Kraken({
api_key: config.kraken.apiKey,
api_secret: config.kraken.apiSecret
});
kraken.upload(options, function(data) {
if (data.success) {
console.log('Success. Optimized image URL: %s', data.kraked_url);
deferred.resolve(data);
} else {
console.log('Fail. Error message: %s', data.error);
deferred.resolve(null);
}
});
I'm debugging kraken.js node library and request seems ok, but I never get the response object. Any idea?
This is one example of these images: http://s18.postimg.org/fv8x7ttqh/unnamed.png
Hi,
I'd like to use Grunt to connect to the Kraken API. However I can't find any documentation on how to setup the Gruntfile, neither here on the GitHub readme nor on the NPM site. Can you please give me an example Gruntfile setup?
I can successfully load images to s3 when loading a local image from my machine using 'fs', however I can't seem to wrap my head around how to do this when uploading the images from a Web Form.
I'm using ExpressJs as my web server and would like to upload the image as a Stream Object, the library clearly supports this from the docs.
With Multer-s3 I can upload to s3, but then loose the Kraken compression.
Can you guys steer me in the right direction to upload images to s3 using Kraken & Stream Objects?
Hi
Can you publish a new version to npm? #17 doesn't seem to be present in the latest release there, for example.
Thanks
The Readme states that the file parameter in the options structure for upload
can be either a file path or a stream object. However, when I try to use a GridFSReadStream source, I get an error related to a call in upload
to stringify the whole options object into formData.data
.
I don't think that the file
option is used in formData.data
since it is already extracted into formData.file
. So, I think this is an easy fix, just set formData.file
first, then delete the opts.file
key beofre stringifying it to formData.data
.
Instead of having a path attribute in url options.
Ever since upgrading to version 0.2.1 I've been getting "Error pushing file to s3" error when calling .url() method
I'm following the docs: https://github.com/kraken-io/kraken-node#amazon-s3-and-rackspace-cloud-files
But if I revert the node module to bdaf51d it works as expected
What am I doing wrong?
Hey guys,
Thank you for your product, it's great and a pleasure to use. One small question though is why you don't follow a fundamental nodejs technique of error first callbacks (more info here: http://fredkschott.com/post/2014/03/understanding-error-first-callbacks-in-node-js/)? Whole node ecosystem is built atop of that principle including fs
and request
packages this repo depends on.
I could make a pull request, but that would break the backwards compatibility. Though if a release with error first callbacks would have a new major version, you could probably avoid most of unwanted breakages because of npm's ^
version locker.
I have some problems with the orientation image with kraken so in the documentation of Kraken.io I see that I can pass the flag auto_orientation: true
but in the SDK for NodeJS I don't see this flag documented
Hello, Im trying to implement Kraken's services to our AWS S3 bucket. When I deploy this code and upload an image into my s3 bucket, Im expecting this service to take the image uploaded to my S3 bucket, optimize it through Kraken and then reupload it into my S3 bucket. It doesnt seem that the images are hitting Kraken when I look at the account overview. In my code I do have my API Keys set. Please advise.
However, I received this error when running my tests:
{ "errorType": "TypeError", "errorMessage": "The \"path\" argument must be of type string or an instance of Buffer or URL. Received undefined", "code": "ERR_INVALID_ARG_TYPE", "stack": [ "TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string or an instance of Buffer or URL. Received undefined", " at Object.open (fs.js:428:10)", " at ReadStream.open (internal/fs/streams.js:131:13)", " at new ReadStream (internal/fs/streams.js:119:10)", " at Object.createReadStream (fs.js:1919:10)", " at module.exports.Kraken.upload (/var/task/node_modules/kraken/lib/kraken.js:92:28)", " at processFile (/var/task/index.js:52:12)", " at Runtime.exports.handler (/var/task/index.js:7:9)", " at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)" ] }
Here is my current code:
`var https = require('https');
var querystring = require('querystring');
var kraken = require('kraken');
exports.handler = (event, context, callback) => {
let records = event.Records;
for (let i = 0; i < records.length; i++) {
processFile(records[i]);
}
};
function processFile(file) {
let filePath = file.s3.object.key;
console.log(file.s3.object);
let fileBucket = file.s3.bucket.name;
console.log('filebucket:' + fileBucket);
console.log('filePath: ' + filePath);
let fileName = filePath.split('/');
fileName = fileName[fileName.length-1];
console.log('fileName: ' + fileName);
if(fileName.indexOf('rl-')===0){
return;
}
if(!(filePath.indexOf('.jpg')>0 || filePath.indexOf('.png')>0)){
return;
}
var Kraken = require('kraken');
var kraken = new Kraken({
'api_key': '{myapikey here}',
'api_secret': '{mysecretapikey here}'
});
var params = {
url: 'https://ericstestbucket2.s3.amazonaws.com/' + fileName,
wait: true,
lossy: false,
resize: {
'width': 100,
'height': 100,
'strategy': 'auto'
},
s3_store: {
key: 'AKIA2PUL6UA5W6RX2DGH',
secret: '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',
path: '/test.jpg',
bucket: 'ericstestbucket2',
region: 'us-east-1',
}
};
console.log(params);
kraken.upload(params, function(err, data) {
if (err) {
console.log('Failed. Error message: %s', err);
} else {
console.log('Success. Optimized image URL: %s', data.kraked_url);
}
});
}`
Latest version of /lib/kraken.js file published on npm differs from the same file at this repository (despite they belong to the same package version). File on npm does not set 'Content-Type' header in Kraken.prototype.url method, so it causes 'Incoming request body does not contain a valid JSON object' error. Please update npm package.
It's the only moderate
or higher rated concern.
Moderate │ Regular Expression Denial of Service
Package │ mime
Patched in │ >= 1.4.1 < 2.0.0 || >= 2.0.3
Dependency of │ kraken
Path │ kraken > mime
More info │ https://nodesecurity.io/advisories/535
can we get a new version bump of kraken with a new version of mime? this should be an easy fix.
When I do this:
import Kraken from 'kraken';
I get a lot of errors. The first one is:
kraken.js:12 Uncaught Error: Cannot find module "fs"
Please fix this.
I'm trying to add a storage class to the optimized image using Kraken.io S3 in NodeJS. Now I know there is an option to add metadata
key to the s3 object, but this prepend -meta
to the request.
For example:
metadata: {"storage-class": "INTELLIGENT_TIERING"}
results in x-amz-meta-storage-class
, but what I actually need is x-amz-storage-class
Is there a way to achieve this without editing the source code? I also tried adding x-amz-storage-class
under headers
with no success, it won’t affect the storage class.
No matter what I try, with or without the Kraken Node library, I get the following error response from Kraken: Incoming request body does not contain a valid JSON object
No hint or tips as to what fields are missing. We include everything, authentication, wait parameter, resize options, etc.
It would be great if this error could provide more details as to what exactly is wrong.
Hello, we've been using this module successfully for a while now, but ran into the seemingly arbitrary limitation of 255 characters for a filename when passing a URL.
We sometimes directly pass avatars hosted on Google to process with Kraken, and these URL's can be quite long (> 255 characters).
Can you please remove or adjust this limitation to say 512 characters at least?
Currently there doesn't seem to be any support in the package for the multi-resize feature. Seen here... http://disq.us/8myw0i
I was just wondering if/when you were looking at implementation of the multi-resize feature into kraken-node
as this would be extremely useful. 👍
Doing:
kraken = new Kraken(
api_key: process.env.KRAKEN_API_KEY
api_secret: process.env.KRAKEN_API_SECRET
)
kraken.url {url: ORIGIN + path, wait: true}, (data) ->
...
results in
{
"success": false,
"error": "Incoming request body does not contain a valid JSON object"
}
Hi Team,
I am trying to use your service specifically for uploading images using Kraken and S3. However, my images are not stored in some url. An image is uploaded by user and I get is a Buffer file.
Is it possible to upload using Krarek with with Buffer type files or other formats stored ins node.js memory?
Below is reference to the specific API/SDK that I am trying to use for Kraken/S3:
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.