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);