Created
          October 23, 2022 18:17 
        
      - 
      
- 
        Save stevedylandev/89f52a25a7a2701c815c000add7ee671 to your computer and use it in GitHub Desktop. 
    Submarining a File via API
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import axios from 'axios' | |
| import FormData from 'form-data' | |
| import fs from 'fs' | |
| const submarineFile = async () => { | |
| const data = new FormData() | |
| data.append(`files`, fs.createReadStream('./path/to/file.png')); | |
| data.append('pinToIPFS', 'false'); | |
| try { | |
| const res = await axios.post("https://managed.mypinata.cloud/api/v1/content", data, { | |
| maxBodyLength: "Infinity", | |
| headers: { | |
| 'x-api-key': 'submarine_api_key' | |
| } | |
| }); | |
| console.log(res.data); | |
| } catch (error) { | |
| console.log(error) | |
| } | |
| }; | |
| submarineFile() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment