aws-s3 icon indicating copy to clipboard operation
aws-s3 copied to clipboard

Not able to upload file

Open hiranvikas77 opened this issue 5 years ago • 3 comments

const config = {
            bucketName: process.env.BUCKET_NAME,
            dirName: `user/${user_id}/checklist/${checklist_id}`,
            region: process.env.REGION,
            accessKeyId: process.env.ACCESS_KEY_ID,
            secretAccessKey: process.env.SECRET_ACCESS_KEY
        }
 
        
        const S3Client = new S3(config);

        S3Client
        .uploadFile(file)
        .then(data => console.log(data))
        .catch(err => console.error(err))
gives Error:
POST https://bucketname.s3-us-east-1.amazonaws.com/ net::ERR_NAME_NOT_RESOLVED
react_devtools_backend.js:2273 TypeError: Failed to fetch

Then if I remove region from config and tries to upload file with param 'File' it gives following error


react_devtools_backend.js:2273 TypeError: Cannot read property 'split' of undefined
    at aws-s3.js:1
    at s../node_modules/aws-s3/dist/aws-s3.js.s.uploadFile (aws-s3.js:1)

This is what File object/ attachment I pass to uploadFile() :

file

if you can help?

hiranvikas77 avatar Aug 10 '20 15:08 hiranvikas77

If it is a react app, then name the variable as REACT_APP_VARIABLE_NAME, this solved the problem for me

zhushangs avatar Feb 06 '21 01:02 zhushangs

@zhushangs what variable exactly?

riteshghodrao avatar Apr 09 '21 14:04 riteshghodrao

@hiranvikas77 : not sure if you have solved the issue but I found a fix

const config = { bucketName: process.env.BUCKET_NAME, dirName: user/${user_id}/checklist/${checklist_id}, region: process.env.REGION, accessKeyId: process.env.ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_ACCESS_KEY, s3Url: 'https://bucketname.s3.amazonaws.com', /* without the suffix zone added */ }

tonyvugithub avatar May 10 '21 22:05 tonyvugithub