title: Is there a way to read or convert object received by request with fs.readFile
body: <p>I need send an uploaded file in front-end to my back-end application to get your hash. I know one way to get a hash file is reading your buffer array (i'm sending an object instead your buffer array).</p>
  
  <p><strong>front-end code:</strong></p>
  
  <pre><code>const [document, setDocument] = useState('');
  
  async function onFileUpload(e) { 
  // Create an object of formData 
  const formData = new FormData(); 
  
  formData.append( 
    "myFile", 
    document,
  ); 
  
  // Request made to the backend api 
  // Send formData object 
  try {
    const response = await api.post('/uploadFile', formData); 
  
    console.log('response' + response);
  } catch (err) {
    console.log('err' + err);
    // alert(`error`);
  }
  </code></pre>
  
  <p>};</p>
  
  <pre><code>&lt;input 
    placeholder="Informe um arquivo"
    type="file"
    name="file"
    onChange={e =&gt; setDocument(e.target.files[0])}
   /&gt;
  
   &lt;button type="submit" onClick={onFileUpload}&gt;Upload&lt;/button&gt;
  </code></pre>
  
  <p><strong>back-end code:</strong></p>
  
  <pre><code>import cryptoJs from 'crypto-js';
  import fs from 'fs';
  
  module.exports = {
    create(request, response) {
  
      console.log('dm:' + request.body)
  
      fs.readFile(request.body, "utf8", function(err,data){
        if(err) {
          console.error("Could not open file: %s", err);
          return response.json(err);
        }else{
          var finalHash = cryptoJs.SHA256(data);
          //upToIPFS(data);
          console.log('hash: ' + finalHash)
          return response.json({ finalHash });
      }})
    }
  }
  </code></pre>
  
  <p>When the file is sent to back-end, i get this error:</p>
  
  <pre><code>TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Object
  </code></pre>
  
  <p>I know that the request received is an object. Is there a way to convert or read the object request? or should i need change front-end code to send proper request?</p>
  
  <p>If a try <code>request.body.document</code> instead just <code>request.body</code> then i get <code>undefined</code> variable.</p>
  
  <p>I'm using react.js and express. node version: v12.16.3</p>