title: IPFS: Calculating the CID V0 of a pdf without fully uploading the file in React js
body: <p>So I need to do get the hash only without actually uploading the whole file to IPFS, exactly like what pinata is doing below in my frontend website using react</p>
  <p><a href="https://i.stack.imgur.com/Hvf2e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hvf2e.png" alt="Pinata CID Checker" /></a></p>
  <p>After some research I found <a href="https://npm.io/package/ipfs-only-hash" rel="nofollow noreferrer">https://npm.io/package/ipfs-only-hash</a></p>
  <p>I am able to generate the IPFS hash for a string as below. But I need it to be generated for a pdf file. How do I do the same for a file that is being done for a string in the below code?</p>
  <pre><code>
  import './App.css';
  import React, {useState} from 'react';
  import Hash from 'ipfs-only-hash'
  
  function App() {
  
    const [file, setFile] = useState()
  
  
    function handleChange(event) {
      setFile(event.target.files[0])
    }
    
    function handleSubmit(event) {
      event.preventDefault()
     // const url = 'http://localhost:3000/uploadFile';
  
      const formData = new FormData();
      formData.append('file', file);
      formData.append('fileName', file.name);
  
      const data = 'Hello World'
      const hash =  Hash.of(data)
      console.log(hash)
  
  
    }
  
    return (
      &lt;div className=&quot;App&quot;&gt;
          &lt;form onSubmit={handleSubmit}&gt;
            &lt;h1&gt;File Upload&lt;/h1&gt;
            &lt;input type=&quot;file&quot; onChange={handleChange}/&gt;
            &lt;button type=&quot;submit&quot;&gt;Upload&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  
  </code></pre>