5 examples of 's3 putobject nodejs' in JavaScript

Every line of 's3 putobject nodejs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
22putObject (region, bucketName, objectName, body, mimeType = undefined, cacheControl = undefined) {
23 const awsS3 = new AWS.S3({ region })
24 return new Promise((resolve, reject) => {
25 if (mimeType === undefined) {
26 mimeType = mime.lookup(objectName)
27 }
28 if (cacheControl === undefined) {
29 cacheControl = getCacheControl(mimeType)
30 }
31 const params = {
32 Bucket: bucketName,
33 Body: body,
34 Key: objectName,
35 ContentType: mimeType,
36 CacheControl: cacheControl
37 }
38 awsS3.putObject(params, (err, result) => {
39 if (err) {
40 return reject(err)
41 }
42 resolve()
43 })
44 })
45}
50function uploadFile(s3, fileName, contents, callback) {
51 s3.putObject({
52 ACL: 'public-read',
53 Body: contents,
54 Bucket: 'ember-graph-builds',
55 ContentType: (fileName.endsWith('.zip') ? 'application/zip' : 'application/javascript'),
56 Key: fileName
57 }, function(err, data) {
58 callback(!err, fileName);
59 });
60}
27public async putFile(deployBucketName: string, localFilePath: string, s3Key: string): Promise {
28 logging.print(colors.white('upload %s'), localFilePath);
29 return this.s3.putObject({
30 Bucket: deployBucketName,
31 Key: s3Key,
32 Body: fs.readFileSync(localFilePath)
33 }).promise();
34}
157_put_object(params) {
158 return P.ninvoke(this.s3cloud, 'putObject', params)
159 .catch(err => {
160 if (this._try_change_region(err)) {
161 return this._put_object(params);
162 }
163 dbg.error('_write_block failed:', err, this.cloud_info);
164 throw err;
165 });
166}
13function uploadToS3(options) {
14 var s3 = require('s3');
15
16 var client = s3.createClient({
17 s3Options: {
18 accessKeyId: options.key,
19 secretAccessKey: options.secret,
20 },
21 });
22
23 var params = {
24 localFile: options.path,
25
26 s3Params: {
27 Bucket: options.bucket,
28 Key: options.name || options.path,
29 },
30 };
31 var uploader = client.uploadFile(params);
32
33 return uploader;
34}

Related snippets