0

I'm trying to upload a file to Pinata IPFS using curl and php.

I attempted to modify the existing code from the question below but I'm getting {"error":{"reason":"INVALID_ROUTE","details":"The provided route does not match a valid Pinata endpoint"}}

How to properly upload files to pinata ipfs using curl php

Here is the modified code from the link above:

$url = "https://api.pinata.cloud/pinning/pinFileToIPFS";

$boundary = uniqid();
$delimiter = '-------------' . $boundary;

$data = array(
'Content-Type' => 'multipart/form-data; boundary=' . $delimiter,
'pinata_api_key' => 'xxxxxxxx',
'pinata_secret_api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx');

$file = 'logo.jpg';
$data['file'] = $file;

$handle = curl_init($url);
curl_setopt($handle, CURLOPT_HEADER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $data);
echo $result = curl_exec($handle);

if (curl_errno($handle)) {
  echo "CURL ERROR - " . curl_error($handle);
}
else {
  echo $result;
}

curl_close($handle);
Rob
  • 1
  • 1
  • Have you read all the comments in the thread you are referring to? – ino Feb 26 '22 at 09:51
  • @ino Yes, I saw the comment where it needs to be sent as a request header. I attempted to do so in the code above but am receiving that error. Is the implementation not correct? – Rob Feb 27 '22 at 17:09

0 Answers0