Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Not able to upload file #78

Open
hiranvikas77 opened this issue Aug 10, 2020 · 3 comments
Open

Not able to upload file #78

hiranvikas77 opened this issue Aug 10, 2020 · 3 comments

Comments

@hiranvikas77
Copy link

hiranvikas77 commented Aug 10, 2020

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?

@zhushangs
Copy link

zhushangs commented Feb 6, 2021

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

@riteshghodrao
Copy link

@zhushangs what variable exactly?

@tonyvugithub
Copy link

@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 */
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants