TypeError: Cannot convert undefined or null to object React JS (S3 multipart file upload)











up vote
1
down vote

favorite
1












I am trying to upload Image/video files into S3 bucket by using S3 multipart upload method. After that I found ReactS3Uploader npm package. After import this package with my React component I keep getting TypeError: Cannot convert undefined or null to object error message while picking a files from browser.



Error message:



        Pre-process: 2.png
Upload progress: 0% Waiting

Uncaught TypeError: Cannot convert undefined or null to object
at Function.assign (<anonymous>)
at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 (s3upload.js:64)
at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile (s3upload.js:95)
at S3Upload.<anonymous> (s3upload.js:57)
at S3Upload.preprocess (ReactS3Uploader.js:35)
at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect (s3upload.js:55)
at new S3Upload (s3upload.js:47)
at Object.uploadFile (ReactS3Uploader.js:56)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:265)
at executeDispatch (react-dom.development.js:571)
at executeDispatchesInOrder (react-dom.development.js:596)
at executeDispatchesAndRelease (react-dom.development.js:695)
at executeDispatchesAndReleaseTopLevel (react-dom.development.js:704)
at forEachAccumulated (react-dom.development.js:676)
at runEventsInBatch (react-dom.development.js:844)
at runExtractedEventsInBatch (react-dom.development.js:852)
at handleTopLevel (react-dom.development.js:5025)
at batchedUpdates$1 (react-dom.development.js:19904)
at batchedUpdates (react-dom.development.js:2246)
at dispatchEvent (react-dom.development.js:5105)
push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 @ s3upload.js:64
push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile @ s3upload.js:95
(anonymous) @ s3upload.js:57
preprocess @ ReactS3Uploader.js:35
push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect @ s3upload.js:55
S3Upload @ s3upload.js:47
uploadFile @ ReactS3Uploader.js:56
callCallback @ react-dom.development.js:147
invokeGuardedCallbackDev @ react-dom.development.js:196
invokeGuardedCallback @ react-dom.development.js:250
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:265
executeDispatch @ react-dom.development.js:571
executeDispatchesInOrder @ react-dom.development.js:596
executeDispatchesAndRelease @ react-dom.development.js:695
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:704
forEachAccumulated @ react-dom.development.js:676
runEventsInBatch @ react-dom.development.js:844
runExtractedEventsInBatch @ react-dom.development.js:852
handleTopLevel @ react-dom.development.js:5025
batchedUpdates$1 @ react-dom.development.js:19904
batchedUpdates @ react-dom.development.js:2246
dispatchEvent @ react-dom.development.js:5105


Here is my code sample,



import React, { Component } from 'react';
import './App.css';
var ReactS3Uploader = require('react-s3-uploader-multipart');
class App extends Component {
render() {
return (
<div className="App">
<ReactS3Uploader
signingUrl="/s3/sign"
signingUrlMethod="GET"
accept="image/*"
s3path="/uploads/"
preprocess={this.onUploadStart}
onProgress={this.onUploadProgress}
onError={this.onUploadError}
onFinish={this.onUploadFinish}
signingUrlWithCredentials={true}
uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
contentDisposition="auto"
scrubFilename={(filename) =>
filename.replace(/[^wd_-.]+/ig, '')}
server="http://cross-origin-server.com"
inputRef={cmp => this.uploadInput = cmp}
autoUpload={true}
/>
</div>
);
}
}

export default App;


Package.json :



   {
"name": "s3",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-s3-uploader-multipart": "^4.8.0",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}


Thanks in advance.










share|improve this question




























    up vote
    1
    down vote

    favorite
    1












    I am trying to upload Image/video files into S3 bucket by using S3 multipart upload method. After that I found ReactS3Uploader npm package. After import this package with my React component I keep getting TypeError: Cannot convert undefined or null to object error message while picking a files from browser.



    Error message:



            Pre-process: 2.png
    Upload progress: 0% Waiting

    Uncaught TypeError: Cannot convert undefined or null to object
    at Function.assign (<anonymous>)
    at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 (s3upload.js:64)
    at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile (s3upload.js:95)
    at S3Upload.<anonymous> (s3upload.js:57)
    at S3Upload.preprocess (ReactS3Uploader.js:35)
    at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect (s3upload.js:55)
    at new S3Upload (s3upload.js:47)
    at Object.uploadFile (ReactS3Uploader.js:56)
    at HTMLUnknownElement.callCallback (react-dom.development.js:147)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
    at invokeGuardedCallback (react-dom.development.js:250)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:265)
    at executeDispatch (react-dom.development.js:571)
    at executeDispatchesInOrder (react-dom.development.js:596)
    at executeDispatchesAndRelease (react-dom.development.js:695)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:704)
    at forEachAccumulated (react-dom.development.js:676)
    at runEventsInBatch (react-dom.development.js:844)
    at runExtractedEventsInBatch (react-dom.development.js:852)
    at handleTopLevel (react-dom.development.js:5025)
    at batchedUpdates$1 (react-dom.development.js:19904)
    at batchedUpdates (react-dom.development.js:2246)
    at dispatchEvent (react-dom.development.js:5105)
    push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 @ s3upload.js:64
    push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile @ s3upload.js:95
    (anonymous) @ s3upload.js:57
    preprocess @ ReactS3Uploader.js:35
    push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect @ s3upload.js:55
    S3Upload @ s3upload.js:47
    uploadFile @ ReactS3Uploader.js:56
    callCallback @ react-dom.development.js:147
    invokeGuardedCallbackDev @ react-dom.development.js:196
    invokeGuardedCallback @ react-dom.development.js:250
    invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:265
    executeDispatch @ react-dom.development.js:571
    executeDispatchesInOrder @ react-dom.development.js:596
    executeDispatchesAndRelease @ react-dom.development.js:695
    executeDispatchesAndReleaseTopLevel @ react-dom.development.js:704
    forEachAccumulated @ react-dom.development.js:676
    runEventsInBatch @ react-dom.development.js:844
    runExtractedEventsInBatch @ react-dom.development.js:852
    handleTopLevel @ react-dom.development.js:5025
    batchedUpdates$1 @ react-dom.development.js:19904
    batchedUpdates @ react-dom.development.js:2246
    dispatchEvent @ react-dom.development.js:5105


    Here is my code sample,



    import React, { Component } from 'react';
    import './App.css';
    var ReactS3Uploader = require('react-s3-uploader-multipart');
    class App extends Component {
    render() {
    return (
    <div className="App">
    <ReactS3Uploader
    signingUrl="/s3/sign"
    signingUrlMethod="GET"
    accept="image/*"
    s3path="/uploads/"
    preprocess={this.onUploadStart}
    onProgress={this.onUploadProgress}
    onError={this.onUploadError}
    onFinish={this.onUploadFinish}
    signingUrlWithCredentials={true}
    uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
    contentDisposition="auto"
    scrubFilename={(filename) =>
    filename.replace(/[^wd_-.]+/ig, '')}
    server="http://cross-origin-server.com"
    inputRef={cmp => this.uploadInput = cmp}
    autoUpload={true}
    />
    </div>
    );
    }
    }

    export default App;


    Package.json :



       {
    "name": "s3",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
    "react": "^16.6.1",
    "react-dom": "^16.6.1",
    "react-s3-uploader-multipart": "^4.8.0",
    "react-scripts": "2.1.1"
    },
    "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
    },
    "eslintConfig": {
    "extends": "react-app"
    },
    "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
    ]
    }


    Thanks in advance.










    share|improve this question


























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      I am trying to upload Image/video files into S3 bucket by using S3 multipart upload method. After that I found ReactS3Uploader npm package. After import this package with my React component I keep getting TypeError: Cannot convert undefined or null to object error message while picking a files from browser.



      Error message:



              Pre-process: 2.png
      Upload progress: 0% Waiting

      Uncaught TypeError: Cannot convert undefined or null to object
      at Function.assign (<anonymous>)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 (s3upload.js:64)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile (s3upload.js:95)
      at S3Upload.<anonymous> (s3upload.js:57)
      at S3Upload.preprocess (ReactS3Uploader.js:35)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect (s3upload.js:55)
      at new S3Upload (s3upload.js:47)
      at Object.uploadFile (ReactS3Uploader.js:56)
      at HTMLUnknownElement.callCallback (react-dom.development.js:147)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
      at invokeGuardedCallback (react-dom.development.js:250)
      at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:265)
      at executeDispatch (react-dom.development.js:571)
      at executeDispatchesInOrder (react-dom.development.js:596)
      at executeDispatchesAndRelease (react-dom.development.js:695)
      at executeDispatchesAndReleaseTopLevel (react-dom.development.js:704)
      at forEachAccumulated (react-dom.development.js:676)
      at runEventsInBatch (react-dom.development.js:844)
      at runExtractedEventsInBatch (react-dom.development.js:852)
      at handleTopLevel (react-dom.development.js:5025)
      at batchedUpdates$1 (react-dom.development.js:19904)
      at batchedUpdates (react-dom.development.js:2246)
      at dispatchEvent (react-dom.development.js:5105)
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 @ s3upload.js:64
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile @ s3upload.js:95
      (anonymous) @ s3upload.js:57
      preprocess @ ReactS3Uploader.js:35
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect @ s3upload.js:55
      S3Upload @ s3upload.js:47
      uploadFile @ ReactS3Uploader.js:56
      callCallback @ react-dom.development.js:147
      invokeGuardedCallbackDev @ react-dom.development.js:196
      invokeGuardedCallback @ react-dom.development.js:250
      invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:265
      executeDispatch @ react-dom.development.js:571
      executeDispatchesInOrder @ react-dom.development.js:596
      executeDispatchesAndRelease @ react-dom.development.js:695
      executeDispatchesAndReleaseTopLevel @ react-dom.development.js:704
      forEachAccumulated @ react-dom.development.js:676
      runEventsInBatch @ react-dom.development.js:844
      runExtractedEventsInBatch @ react-dom.development.js:852
      handleTopLevel @ react-dom.development.js:5025
      batchedUpdates$1 @ react-dom.development.js:19904
      batchedUpdates @ react-dom.development.js:2246
      dispatchEvent @ react-dom.development.js:5105


      Here is my code sample,



      import React, { Component } from 'react';
      import './App.css';
      var ReactS3Uploader = require('react-s3-uploader-multipart');
      class App extends Component {
      render() {
      return (
      <div className="App">
      <ReactS3Uploader
      signingUrl="/s3/sign"
      signingUrlMethod="GET"
      accept="image/*"
      s3path="/uploads/"
      preprocess={this.onUploadStart}
      onProgress={this.onUploadProgress}
      onError={this.onUploadError}
      onFinish={this.onUploadFinish}
      signingUrlWithCredentials={true}
      uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
      contentDisposition="auto"
      scrubFilename={(filename) =>
      filename.replace(/[^wd_-.]+/ig, '')}
      server="http://cross-origin-server.com"
      inputRef={cmp => this.uploadInput = cmp}
      autoUpload={true}
      />
      </div>
      );
      }
      }

      export default App;


      Package.json :



         {
      "name": "s3",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
      "react": "^16.6.1",
      "react-dom": "^16.6.1",
      "react-s3-uploader-multipart": "^4.8.0",
      "react-scripts": "2.1.1"
      },
      "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
      },
      "eslintConfig": {
      "extends": "react-app"
      },
      "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
      ]
      }


      Thanks in advance.










      share|improve this question















      I am trying to upload Image/video files into S3 bucket by using S3 multipart upload method. After that I found ReactS3Uploader npm package. After import this package with my React component I keep getting TypeError: Cannot convert undefined or null to object error message while picking a files from browser.



      Error message:



              Pre-process: 2.png
      Upload progress: 0% Waiting

      Uncaught TypeError: Cannot convert undefined or null to object
      at Function.assign (<anonymous>)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 (s3upload.js:64)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile (s3upload.js:95)
      at S3Upload.<anonymous> (s3upload.js:57)
      at S3Upload.preprocess (ReactS3Uploader.js:35)
      at S3Upload.push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect (s3upload.js:55)
      at new S3Upload (s3upload.js:47)
      at Object.uploadFile (ReactS3Uploader.js:56)
      at HTMLUnknownElement.callCallback (react-dom.development.js:147)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
      at invokeGuardedCallback (react-dom.development.js:250)
      at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:265)
      at executeDispatch (react-dom.development.js:571)
      at executeDispatchesInOrder (react-dom.development.js:596)
      at executeDispatchesAndRelease (react-dom.development.js:695)
      at executeDispatchesAndReleaseTopLevel (react-dom.development.js:704)
      at forEachAccumulated (react-dom.development.js:676)
      at runEventsInBatch (react-dom.development.js:844)
      at runExtractedEventsInBatch (react-dom.development.js:852)
      at handleTopLevel (react-dom.development.js:5025)
      at batchedUpdates$1 (react-dom.development.js:19904)
      at batchedUpdates (react-dom.development.js:2246)
      at dispatchEvent (react-dom.development.js:5105)
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadToS3 @ s3upload.js:64
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.uploadFile @ s3upload.js:95
      (anonymous) @ s3upload.js:57
      preprocess @ ReactS3Uploader.js:35
      push../node_modules/react-s3-uploader-multipart/s3upload.js.S3Upload.handleFileSelect @ s3upload.js:55
      S3Upload @ s3upload.js:47
      uploadFile @ ReactS3Uploader.js:56
      callCallback @ react-dom.development.js:147
      invokeGuardedCallbackDev @ react-dom.development.js:196
      invokeGuardedCallback @ react-dom.development.js:250
      invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:265
      executeDispatch @ react-dom.development.js:571
      executeDispatchesInOrder @ react-dom.development.js:596
      executeDispatchesAndRelease @ react-dom.development.js:695
      executeDispatchesAndReleaseTopLevel @ react-dom.development.js:704
      forEachAccumulated @ react-dom.development.js:676
      runEventsInBatch @ react-dom.development.js:844
      runExtractedEventsInBatch @ react-dom.development.js:852
      handleTopLevel @ react-dom.development.js:5025
      batchedUpdates$1 @ react-dom.development.js:19904
      batchedUpdates @ react-dom.development.js:2246
      dispatchEvent @ react-dom.development.js:5105


      Here is my code sample,



      import React, { Component } from 'react';
      import './App.css';
      var ReactS3Uploader = require('react-s3-uploader-multipart');
      class App extends Component {
      render() {
      return (
      <div className="App">
      <ReactS3Uploader
      signingUrl="/s3/sign"
      signingUrlMethod="GET"
      accept="image/*"
      s3path="/uploads/"
      preprocess={this.onUploadStart}
      onProgress={this.onUploadProgress}
      onError={this.onUploadError}
      onFinish={this.onUploadFinish}
      signingUrlWithCredentials={true}
      uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
      contentDisposition="auto"
      scrubFilename={(filename) =>
      filename.replace(/[^wd_-.]+/ig, '')}
      server="http://cross-origin-server.com"
      inputRef={cmp => this.uploadInput = cmp}
      autoUpload={true}
      />
      </div>
      );
      }
      }

      export default App;


      Package.json :



         {
      "name": "s3",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
      "react": "^16.6.1",
      "react-dom": "^16.6.1",
      "react-s3-uploader-multipart": "^4.8.0",
      "react-scripts": "2.1.1"
      },
      "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
      },
      "eslintConfig": {
      "extends": "react-app"
      },
      "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
      ]
      }


      Thanks in advance.







      reactjs amazon-s3 multipartform-data






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 11:40

























      asked Nov 8 at 11:11









      Arun

      256




      256
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          react-s3-uploader-multipart module can't be used without some modification to its source code.



          You see, the error logged to the console happens as a result of the object assignment on Line 63 of s3Upload.js



          var evaporateOptions = Object.assign(this.evaporateOptions, {
          signerUrl: this.signingUrl
          });


          This reason that this occurs is that when S3Upload is called in line 65 of ReactS3Upload.js, it doesn't forward evaporateOptions property which must be set when creating the ReactS3Uploader React Element.



              this.myUploader = new S3Upload({
          fileElement: ReactDOM.findDOMNode(this),
          signingUrl: this.props.signingUrl,
          getSignedUrl: this.props.getSignedUrl,
          preprocess: this.props.preprocess,
          onProgress: this.props.onProgress,
          onFinishS3Put: this.props.onFinish,
          onError: this.props.onError,
          signingUrlMethod: this.props.signingUrlMethod,
          signingUrlHeaders: this.props.signingUrlHeaders,
          signingUrlQueryParams: this.props.signingUrlQueryParams,
          signingUrlWithCredentials: this.props.signingUrlWithCredentials,
          uploadRequestHeaders: this.props.uploadRequestHeaders,
          contentDisposition: this.props.contentDisposition,
          server: this.props.server,
          scrubFilename: this.props.scrubFilename,
          s3path: this.props.s3path,
          evaporateOptions: this.props.evaporateOptions // this is missing
          });


          Also in Line 68 and Line 103 of s3upload.js, this.s3Path is undefined, rather the property access in those lines should be this.s3path



          This leaves you with the option of making a fork of the repository, doing this change and making a pull request for it to be merged to the upstream and deployed to npm registry
          or looking in the npm package registry for another one.



          If you make this change then evaporateOptions must be passed as props. e.g.



          import crypto from 'crypto';

          const config = {
          signerUrl: 'auth_upload',
          aws_key: 'AKALN0L7ASDFLKJH',
          bucket: 'my-big-bucket',
          computeContentMd5: true,
          cryptoHexEncodedHash256: data => crypto.createHash('sha256').update(data).digest('hex'),
          cryptoMd5Method: data => crypto.createHash('md5').update(data).digest('base64')
          };

          <ReactS3Uploader
          accept="image/*"
          s3path="uploads/"
          signingUrlWithCredentials={true}
          uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
          contentDisposition="auto"
          server="<backend-svc>"
          inputRef={ref => (this.uploadInput = ref)}
          evaporateOptions={config}
          />


          Also, an endpoint in a backing service needs to be implemented for signing the S3 upload URL.
          See this /sign express route to get an example of how that is implemented.






          share|improve this answer























          • Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
            – Arun
            Nov 12 at 14:26










          • What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
            – Oluwafemi Sule
            Nov 12 at 19:59











          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',
          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%2f53206566%2ftypeerror-cannot-convert-undefined-or-null-to-object-react-js-s3-multipart-fil%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          react-s3-uploader-multipart module can't be used without some modification to its source code.



          You see, the error logged to the console happens as a result of the object assignment on Line 63 of s3Upload.js



          var evaporateOptions = Object.assign(this.evaporateOptions, {
          signerUrl: this.signingUrl
          });


          This reason that this occurs is that when S3Upload is called in line 65 of ReactS3Upload.js, it doesn't forward evaporateOptions property which must be set when creating the ReactS3Uploader React Element.



              this.myUploader = new S3Upload({
          fileElement: ReactDOM.findDOMNode(this),
          signingUrl: this.props.signingUrl,
          getSignedUrl: this.props.getSignedUrl,
          preprocess: this.props.preprocess,
          onProgress: this.props.onProgress,
          onFinishS3Put: this.props.onFinish,
          onError: this.props.onError,
          signingUrlMethod: this.props.signingUrlMethod,
          signingUrlHeaders: this.props.signingUrlHeaders,
          signingUrlQueryParams: this.props.signingUrlQueryParams,
          signingUrlWithCredentials: this.props.signingUrlWithCredentials,
          uploadRequestHeaders: this.props.uploadRequestHeaders,
          contentDisposition: this.props.contentDisposition,
          server: this.props.server,
          scrubFilename: this.props.scrubFilename,
          s3path: this.props.s3path,
          evaporateOptions: this.props.evaporateOptions // this is missing
          });


          Also in Line 68 and Line 103 of s3upload.js, this.s3Path is undefined, rather the property access in those lines should be this.s3path



          This leaves you with the option of making a fork of the repository, doing this change and making a pull request for it to be merged to the upstream and deployed to npm registry
          or looking in the npm package registry for another one.



          If you make this change then evaporateOptions must be passed as props. e.g.



          import crypto from 'crypto';

          const config = {
          signerUrl: 'auth_upload',
          aws_key: 'AKALN0L7ASDFLKJH',
          bucket: 'my-big-bucket',
          computeContentMd5: true,
          cryptoHexEncodedHash256: data => crypto.createHash('sha256').update(data).digest('hex'),
          cryptoMd5Method: data => crypto.createHash('md5').update(data).digest('base64')
          };

          <ReactS3Uploader
          accept="image/*"
          s3path="uploads/"
          signingUrlWithCredentials={true}
          uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
          contentDisposition="auto"
          server="<backend-svc>"
          inputRef={ref => (this.uploadInput = ref)}
          evaporateOptions={config}
          />


          Also, an endpoint in a backing service needs to be implemented for signing the S3 upload URL.
          See this /sign express route to get an example of how that is implemented.






          share|improve this answer























          • Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
            – Arun
            Nov 12 at 14:26










          • What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
            – Oluwafemi Sule
            Nov 12 at 19:59















          up vote
          1
          down vote













          react-s3-uploader-multipart module can't be used without some modification to its source code.



          You see, the error logged to the console happens as a result of the object assignment on Line 63 of s3Upload.js



          var evaporateOptions = Object.assign(this.evaporateOptions, {
          signerUrl: this.signingUrl
          });


          This reason that this occurs is that when S3Upload is called in line 65 of ReactS3Upload.js, it doesn't forward evaporateOptions property which must be set when creating the ReactS3Uploader React Element.



              this.myUploader = new S3Upload({
          fileElement: ReactDOM.findDOMNode(this),
          signingUrl: this.props.signingUrl,
          getSignedUrl: this.props.getSignedUrl,
          preprocess: this.props.preprocess,
          onProgress: this.props.onProgress,
          onFinishS3Put: this.props.onFinish,
          onError: this.props.onError,
          signingUrlMethod: this.props.signingUrlMethod,
          signingUrlHeaders: this.props.signingUrlHeaders,
          signingUrlQueryParams: this.props.signingUrlQueryParams,
          signingUrlWithCredentials: this.props.signingUrlWithCredentials,
          uploadRequestHeaders: this.props.uploadRequestHeaders,
          contentDisposition: this.props.contentDisposition,
          server: this.props.server,
          scrubFilename: this.props.scrubFilename,
          s3path: this.props.s3path,
          evaporateOptions: this.props.evaporateOptions // this is missing
          });


          Also in Line 68 and Line 103 of s3upload.js, this.s3Path is undefined, rather the property access in those lines should be this.s3path



          This leaves you with the option of making a fork of the repository, doing this change and making a pull request for it to be merged to the upstream and deployed to npm registry
          or looking in the npm package registry for another one.



          If you make this change then evaporateOptions must be passed as props. e.g.



          import crypto from 'crypto';

          const config = {
          signerUrl: 'auth_upload',
          aws_key: 'AKALN0L7ASDFLKJH',
          bucket: 'my-big-bucket',
          computeContentMd5: true,
          cryptoHexEncodedHash256: data => crypto.createHash('sha256').update(data).digest('hex'),
          cryptoMd5Method: data => crypto.createHash('md5').update(data).digest('base64')
          };

          <ReactS3Uploader
          accept="image/*"
          s3path="uploads/"
          signingUrlWithCredentials={true}
          uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
          contentDisposition="auto"
          server="<backend-svc>"
          inputRef={ref => (this.uploadInput = ref)}
          evaporateOptions={config}
          />


          Also, an endpoint in a backing service needs to be implemented for signing the S3 upload URL.
          See this /sign express route to get an example of how that is implemented.






          share|improve this answer























          • Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
            – Arun
            Nov 12 at 14:26










          • What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
            – Oluwafemi Sule
            Nov 12 at 19:59













          up vote
          1
          down vote










          up vote
          1
          down vote









          react-s3-uploader-multipart module can't be used without some modification to its source code.



          You see, the error logged to the console happens as a result of the object assignment on Line 63 of s3Upload.js



          var evaporateOptions = Object.assign(this.evaporateOptions, {
          signerUrl: this.signingUrl
          });


          This reason that this occurs is that when S3Upload is called in line 65 of ReactS3Upload.js, it doesn't forward evaporateOptions property which must be set when creating the ReactS3Uploader React Element.



              this.myUploader = new S3Upload({
          fileElement: ReactDOM.findDOMNode(this),
          signingUrl: this.props.signingUrl,
          getSignedUrl: this.props.getSignedUrl,
          preprocess: this.props.preprocess,
          onProgress: this.props.onProgress,
          onFinishS3Put: this.props.onFinish,
          onError: this.props.onError,
          signingUrlMethod: this.props.signingUrlMethod,
          signingUrlHeaders: this.props.signingUrlHeaders,
          signingUrlQueryParams: this.props.signingUrlQueryParams,
          signingUrlWithCredentials: this.props.signingUrlWithCredentials,
          uploadRequestHeaders: this.props.uploadRequestHeaders,
          contentDisposition: this.props.contentDisposition,
          server: this.props.server,
          scrubFilename: this.props.scrubFilename,
          s3path: this.props.s3path,
          evaporateOptions: this.props.evaporateOptions // this is missing
          });


          Also in Line 68 and Line 103 of s3upload.js, this.s3Path is undefined, rather the property access in those lines should be this.s3path



          This leaves you with the option of making a fork of the repository, doing this change and making a pull request for it to be merged to the upstream and deployed to npm registry
          or looking in the npm package registry for another one.



          If you make this change then evaporateOptions must be passed as props. e.g.



          import crypto from 'crypto';

          const config = {
          signerUrl: 'auth_upload',
          aws_key: 'AKALN0L7ASDFLKJH',
          bucket: 'my-big-bucket',
          computeContentMd5: true,
          cryptoHexEncodedHash256: data => crypto.createHash('sha256').update(data).digest('hex'),
          cryptoMd5Method: data => crypto.createHash('md5').update(data).digest('base64')
          };

          <ReactS3Uploader
          accept="image/*"
          s3path="uploads/"
          signingUrlWithCredentials={true}
          uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
          contentDisposition="auto"
          server="<backend-svc>"
          inputRef={ref => (this.uploadInput = ref)}
          evaporateOptions={config}
          />


          Also, an endpoint in a backing service needs to be implemented for signing the S3 upload URL.
          See this /sign express route to get an example of how that is implemented.






          share|improve this answer














          react-s3-uploader-multipart module can't be used without some modification to its source code.



          You see, the error logged to the console happens as a result of the object assignment on Line 63 of s3Upload.js



          var evaporateOptions = Object.assign(this.evaporateOptions, {
          signerUrl: this.signingUrl
          });


          This reason that this occurs is that when S3Upload is called in line 65 of ReactS3Upload.js, it doesn't forward evaporateOptions property which must be set when creating the ReactS3Uploader React Element.



              this.myUploader = new S3Upload({
          fileElement: ReactDOM.findDOMNode(this),
          signingUrl: this.props.signingUrl,
          getSignedUrl: this.props.getSignedUrl,
          preprocess: this.props.preprocess,
          onProgress: this.props.onProgress,
          onFinishS3Put: this.props.onFinish,
          onError: this.props.onError,
          signingUrlMethod: this.props.signingUrlMethod,
          signingUrlHeaders: this.props.signingUrlHeaders,
          signingUrlQueryParams: this.props.signingUrlQueryParams,
          signingUrlWithCredentials: this.props.signingUrlWithCredentials,
          uploadRequestHeaders: this.props.uploadRequestHeaders,
          contentDisposition: this.props.contentDisposition,
          server: this.props.server,
          scrubFilename: this.props.scrubFilename,
          s3path: this.props.s3path,
          evaporateOptions: this.props.evaporateOptions // this is missing
          });


          Also in Line 68 and Line 103 of s3upload.js, this.s3Path is undefined, rather the property access in those lines should be this.s3path



          This leaves you with the option of making a fork of the repository, doing this change and making a pull request for it to be merged to the upstream and deployed to npm registry
          or looking in the npm package registry for another one.



          If you make this change then evaporateOptions must be passed as props. e.g.



          import crypto from 'crypto';

          const config = {
          signerUrl: 'auth_upload',
          aws_key: 'AKALN0L7ASDFLKJH',
          bucket: 'my-big-bucket',
          computeContentMd5: true,
          cryptoHexEncodedHash256: data => crypto.createHash('sha256').update(data).digest('hex'),
          cryptoMd5Method: data => crypto.createHash('md5').update(data).digest('base64')
          };

          <ReactS3Uploader
          accept="image/*"
          s3path="uploads/"
          signingUrlWithCredentials={true}
          uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }}
          contentDisposition="auto"
          server="<backend-svc>"
          inputRef={ref => (this.uploadInput = ref)}
          evaporateOptions={config}
          />


          Also, an endpoint in a backing service needs to be implemented for signing the S3 upload URL.
          See this /sign express route to get an example of how that is implemented.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 19:57

























          answered Nov 11 at 11:18









          Oluwafemi Sule

          10.5k1330




          10.5k1330












          • Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
            – Arun
            Nov 12 at 14:26










          • What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
            – Oluwafemi Sule
            Nov 12 at 19:59


















          • Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
            – Arun
            Nov 12 at 14:26










          • What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
            – Oluwafemi Sule
            Nov 12 at 19:59
















          Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
          – Arun
          Nov 12 at 14:26




          Hi Oluwafemi, Thanks for responding. I made that change but still I am getting the same error. I added that missing line in node_module/ReactS3Uploader. And I dont understand the PR part, can you explain some detailed?
          – Arun
          Nov 12 at 14:26












          What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
          – Oluwafemi Sule
          Nov 12 at 19:59




          What I imply is to open a pull request in the Github repository to resolve this issues. The changes you make in your local node modules are only temporal
          – Oluwafemi Sule
          Nov 12 at 19:59


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53206566%2ftypeerror-cannot-convert-undefined-or-null-to-object-react-js-s3-multipart-fil%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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini