odysseyscience / react-s3-uploader

React component that renders an <input type="file"/> and automatically uploads to an S3 bucket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting CORS error on uploading file on AWS S3

abhimanusharma opened this issue · comments

Here is my jsx code:

<ReactS3Uploader
    getSignedUrl={props.getSignedUrl}
    accept="image/*"
    onProgress={onProgress}
    onError={onError}
    onFinish={onFinish}
    uploadRequestHeaders={{
        'x-amz-acl': 'public-read'
    }}
    contentDisposition="auto"
/>

Here is my method:

getSignedUrl = async (file, callback) => {
    const { dispatch } = this.props;
    const params = {
      objectName: file.name,
      contentType: file.type
    };
    const response = await dispatch(getSignedUrl(params));
    console.log(response);
    callback(response);
    
  }

The above dispatch method is getting signed url from my NestJs server.

Here is my error:
Screenshot from 2021-07-02 12-55-17

@abhimanusharma were you able to solve this?

Also getting a cors issue when uploading, it would be good to know if there is something wrong or it's just something in the server settings