node-s3 | Node.js AWS S3 application | Cloud Storage library
kandi X-RAY | node-s3 Summary
kandi X-RAY | node-s3 Summary
node-s3 is a simple web application for creating and manipulating buckets and files on Amazon Web Services S3. With slight modifications, you can also use it to proxy file uploads directly to AWS. This basis for this little app was, in part, inspired by: The above link should hopefully provide some insight on how this app might be useful.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Stream upload handler .
- Calculate the MD5 hash .
- Streaming upload .
- save upload handler
- Display the form
- get bucket name
- Generate an options object .
- Delete file .
- Initialize the express server .
- Convert an array of big - endian words to a decoded string .
node-s3 Key Features
node-s3 Examples and Code Snippets
Community Discussions
Trending Discussions on node-s3
QUESTION
Summary
I'm building a desktop app using React and Electron. It's purpose is to install files to coder defined directory. Files come from amazon S3. I'm using a Material UI Framework for a loading bar, and SnackBar popup to show user success. To download, I am using this library: https://github.com/tytech3/node-s3-client
Using this library exposes the byte values coming in and total byte values we need, therefore giving me a percentage to my progress bar.
The problem
I am using events, namely ipcMain and ipcRenderer, to pass this information. Main.js (the file that plays with the OS):
...ANSWER
Answered 2019-Dec-27 at 21:21Ended up figuring it out. The event listeners were never removed. Added 2 lines (see lines starting with +) to remove listeners. I believe ipcRenderer.on actually creates a new listener, which is why i was getting more and more.
QUESTION
I am not able to decrypt my messages I receive from my S3 bucket. They are encrypted with a KMS key. I use Node and Typescript.
I have tried some stuff but arrent able to make it work. Looking in to this links: https://github.com/gilt/node-s3-encryption-client/issues/3 and https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html
My code look like this now:
...ANSWER
Answered 2019-Feb-11 at 13:02I was got some help from coworker and we could figuring it out. The problem was with the
const decipher = crypto.createDecipheriv( algo, kmsKeys.Plaintext[0], new Buffer(iv, 'base64'));
We needed to change the kms.Plaintext
to kms.Plaintext as Buffer
and it start working. I post my hole funktion here if someone needs it for later.
QUESTION
I am trying to download an S3 object while using node, and have asked this previous question. Code is below. I am declaring my access key credentials as environment variables and have tried both my account access keys as well as an IAm role. I have tried generating multiple keys, profiles, buckets and files, as well as creating a bucket policy, all of which have resulted in the following stack trace below. Am I calling the bucket and file objects correctly, as well as setting up my credentials correctly? Is there some other policy or set of configurations I need to make sure set up first before using the aws-sdk to download objects? Thanks!
Code:
...ANSWER
Answered 2017-Oct-27 at 03:07This problem is that you are setting up "config" after creating the S3 Client. Change your code to look like this:
QUESTION
var async = require('async');
var AWS = require('aws-sdk');
var util = require('util');
var im = require('imagemagick');
var fs = require('fs');
// constants
var MAX_WIDTH = 100;
var MAX_HEIGHT = 100;
var s3 = require('s3');
var client = s3.createClient({
maxAsyncS3: 20, // this is the default
s3RetryCount: 3, // this is the default
s3RetryDelay: 1000, // this is the default
multipartUploadThreshold: 20971520, // this is the default (20 MB)
multipartUploadSize: 15728640, // this is the default (15 MB)
s3Options: {
accessKeyId: "xx",
secretAccessKey: "xx",
},
});
exports.handler = function(event, context, callback) {
// Read options from the event.
console.log("Reading options from event:\n", util.inspect(event, {depth: 5}));
var srcBucket = event.Records[0].s3.bucket.name;
// Object key may have spaces or unicode non-ASCII characters.
var srcKey = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " "));
var dstBucket = srcBucket + "resized";
var dstKey = "resized-" + srcKey;
// Sanity check: validate that source and destination are different buckets.
if (srcBucket == dstBucket) {
callback("Source and destination buckets are the same.");
return;
}
// Infer the image type.
var typeMatch = srcKey.match(/\.([^.]*)$/);
if (!typeMatch) {
callback("Could not determine the image type.");
return;
}
var imageType = typeMatch[1];
if (imageType != "jpg" && imageType != "png") {
callback('Unsupported image type: ${imageType}');
return;
}
// Download the image from S3, transform, and upload to a different S3 bucket.
async.waterfall([
function download(next) {
var params = {
localFile: "/tmp/"+srcKey,
s3Params: {
Bucket: srcBucket,
Key: srcKey,
},
};
var downloader = client.downloadFile(params);
downloader.on('error', function(err) {
console.error("unable to download:", err.stack);
});
downloader.on('progress', function() {
console.log("progress", downloader.progressAmount, downloader.progressTotal);
});
downloader.on('end', function() {
console.log("done downloading");
});
//upload a file
var uploadparams = {
localFile: "/tmp/"+srcKey,
s3Params: {
Bucket: dstBucket,
Key: dstKey,
},
};
var uploader = client.uploadFile(uploadparams);
uploader.on('error', function(err) {
console.error("unable to upload:", err.stack);
});
uploader.on('progress', function() {
console.log("progress", uploader.progressMd5Amount,
uploader.progressAmount, uploader.progressTotal);
});
uploader.on('end', function() {
console.log("done uploading");
});
}
], function (err) {
if (err) {
console.error(
'Unable to resize ' + srcBucket + '/' + srcKey +
' and upload to ' + destBucket + '/' + destKey +
' due to an error: ' + err
);
} else {
console.log(
'Successfully resized ' + srcBucket + '/' + srcKey +
' and uploaded to ' + destBucket + '/' + destKey
);
}
}
);
};
...ANSWER
Answered 2017-Jul-30 at 16:50You are trying to upload at the same time you are downloading...
You need to call upload inside downloader.on('end',
method
QUESTION
I'm using the node-s3-client library to upload files to my bucket.
I have a local folder, /build
, that I would like to upload to a folder within an S3 bucket, entitled Library
.
Placing individual files into the Library folder is easy:
...ANSWER
Answered 2017-Feb-01 at 21:50Use Prefix
instead of Key
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-s3
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page