AWS - Node SDK uploading file successfully to a S3 Bucket but not appear into Bucket





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to upload image into AWS-S3-Bucket via using AWS Node SDK. It makes request with successful response but when I go to my S3-Bucket, file does not exist.



I try my best to sort out this issue, visit so many forums but there is no luck. Please help me on it, here is my code:



......
const bucketName = "myBucket";

const baseObject = "uploads/";
let defaults = {
// Your SECRET ACCESS KEY from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.SECRET_ACCESS_KEY
secretAccessKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
// Not working key, Your ACCESS KEY ID from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.ACCESS_KEY_ID
accessKeyId: "xxxxxxxxxxxxxxxx",
region: "us-east-1", // region of your bucket
// region: "us-west-2", // region of your bucket

Bucket: bucketName,
};


let settings = Object.assign({}, defaults, options); // values in options override values in defaults
// console.log(settings); // Object {key1: "value1", key2: "default2", key3: "defaults3"}

aws.config.update(settings);

// Create name for uploaded object key
var keyName =`${baseObject}${options.keyName}${Date.now().toString()}`;

const base64StringData = options.body;
let imageBody = base64StringData.replace(/^data:image/w+;base64,/, "");
// Getting the file type, ie: jpeg, png or gif
const type = base64StringData.split(";")[0].split("/")[1];

let buffer = new Buffer(imageBody, "base64");
let objectParams = {
Bucket: bucketName,
Key: `${keyName}.${type}`,
ACL: "public-read",
Body: buffer,
ContentEncoding: "base64",
ContentType: `image/${type}`,
ContentLength: buffer.length,
};
console.log(objectParams);
const s3 = new aws.S3();
await s3.putObject(objectParams)
......









share|improve this question























  • Do you have the specific permission to check the bucket/object in console?

    – Sigcont
    Nov 27 '18 at 13:24


















0















I am trying to upload image into AWS-S3-Bucket via using AWS Node SDK. It makes request with successful response but when I go to my S3-Bucket, file does not exist.



I try my best to sort out this issue, visit so many forums but there is no luck. Please help me on it, here is my code:



......
const bucketName = "myBucket";

const baseObject = "uploads/";
let defaults = {
// Your SECRET ACCESS KEY from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.SECRET_ACCESS_KEY
secretAccessKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
// Not working key, Your ACCESS KEY ID from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.ACCESS_KEY_ID
accessKeyId: "xxxxxxxxxxxxxxxx",
region: "us-east-1", // region of your bucket
// region: "us-west-2", // region of your bucket

Bucket: bucketName,
};


let settings = Object.assign({}, defaults, options); // values in options override values in defaults
// console.log(settings); // Object {key1: "value1", key2: "default2", key3: "defaults3"}

aws.config.update(settings);

// Create name for uploaded object key
var keyName =`${baseObject}${options.keyName}${Date.now().toString()}`;

const base64StringData = options.body;
let imageBody = base64StringData.replace(/^data:image/w+;base64,/, "");
// Getting the file type, ie: jpeg, png or gif
const type = base64StringData.split(";")[0].split("/")[1];

let buffer = new Buffer(imageBody, "base64");
let objectParams = {
Bucket: bucketName,
Key: `${keyName}.${type}`,
ACL: "public-read",
Body: buffer,
ContentEncoding: "base64",
ContentType: `image/${type}`,
ContentLength: buffer.length,
};
console.log(objectParams);
const s3 = new aws.S3();
await s3.putObject(objectParams)
......









share|improve this question























  • Do you have the specific permission to check the bucket/object in console?

    – Sigcont
    Nov 27 '18 at 13:24














0












0








0








I am trying to upload image into AWS-S3-Bucket via using AWS Node SDK. It makes request with successful response but when I go to my S3-Bucket, file does not exist.



I try my best to sort out this issue, visit so many forums but there is no luck. Please help me on it, here is my code:



......
const bucketName = "myBucket";

const baseObject = "uploads/";
let defaults = {
// Your SECRET ACCESS KEY from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.SECRET_ACCESS_KEY
secretAccessKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
// Not working key, Your ACCESS KEY ID from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.ACCESS_KEY_ID
accessKeyId: "xxxxxxxxxxxxxxxx",
region: "us-east-1", // region of your bucket
// region: "us-west-2", // region of your bucket

Bucket: bucketName,
};


let settings = Object.assign({}, defaults, options); // values in options override values in defaults
// console.log(settings); // Object {key1: "value1", key2: "default2", key3: "defaults3"}

aws.config.update(settings);

// Create name for uploaded object key
var keyName =`${baseObject}${options.keyName}${Date.now().toString()}`;

const base64StringData = options.body;
let imageBody = base64StringData.replace(/^data:image/w+;base64,/, "");
// Getting the file type, ie: jpeg, png or gif
const type = base64StringData.split(";")[0].split("/")[1];

let buffer = new Buffer(imageBody, "base64");
let objectParams = {
Bucket: bucketName,
Key: `${keyName}.${type}`,
ACL: "public-read",
Body: buffer,
ContentEncoding: "base64",
ContentType: `image/${type}`,
ContentLength: buffer.length,
};
console.log(objectParams);
const s3 = new aws.S3();
await s3.putObject(objectParams)
......









share|improve this question














I am trying to upload image into AWS-S3-Bucket via using AWS Node SDK. It makes request with successful response but when I go to my S3-Bucket, file does not exist.



I try my best to sort out this issue, visit so many forums but there is no luck. Please help me on it, here is my code:



......
const bucketName = "myBucket";

const baseObject = "uploads/";
let defaults = {
// Your SECRET ACCESS KEY from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.SECRET_ACCESS_KEY
secretAccessKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
// Not working key, Your ACCESS KEY ID from AWS should go here,
// Never share it!
// Setup Env Variable, e.g: process.env.ACCESS_KEY_ID
accessKeyId: "xxxxxxxxxxxxxxxx",
region: "us-east-1", // region of your bucket
// region: "us-west-2", // region of your bucket

Bucket: bucketName,
};


let settings = Object.assign({}, defaults, options); // values in options override values in defaults
// console.log(settings); // Object {key1: "value1", key2: "default2", key3: "defaults3"}

aws.config.update(settings);

// Create name for uploaded object key
var keyName =`${baseObject}${options.keyName}${Date.now().toString()}`;

const base64StringData = options.body;
let imageBody = base64StringData.replace(/^data:image/w+;base64,/, "");
// Getting the file type, ie: jpeg, png or gif
const type = base64StringData.split(";")[0].split("/")[1];

let buffer = new Buffer(imageBody, "base64");
let objectParams = {
Bucket: bucketName,
Key: `${keyName}.${type}`,
ACL: "public-read",
Body: buffer,
ContentEncoding: "base64",
ContentType: `image/${type}`,
ContentLength: buffer.length,
};
console.log(objectParams);
const s3 = new aws.S3();
await s3.putObject(objectParams)
......






node.js amazon-s3 aws-sdk aws-serverless






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 16:54









TechnicalKeeraTechnicalKeera

347214




347214













  • Do you have the specific permission to check the bucket/object in console?

    – Sigcont
    Nov 27 '18 at 13:24



















  • Do you have the specific permission to check the bucket/object in console?

    – Sigcont
    Nov 27 '18 at 13:24

















Do you have the specific permission to check the bucket/object in console?

– Sigcont
Nov 27 '18 at 13:24





Do you have the specific permission to check the bucket/object in console?

– Sigcont
Nov 27 '18 at 13:24












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485721%2faws-node-sdk-uploading-file-successfully-to-a-s3-bucket-but-not-appear-into-bu%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53485721%2faws-node-sdk-uploading-file-successfully-to-a-s3-bucket-but-not-appear-into-bu%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen