$post_url = “https://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=apikey”;
$upload_file = new CURLFile(‘https://dl.airtable.com/.attachments/4b3ae7d535258081f030e2552b667693/6a41a2b5/download3.png’,'multipart/form-data’);
$file_options = array(
“access” => “PUBLIC_INDEXABLE”,
“ttl” => “P3M”,
“overwrite” => true,
“duplicateValidationStrategy” => “NONE”,
“duplicateValidationScope” => “ENTIRE_PORTAL”
);
$post_data = array(
“file” => $upload_file,
“options” => json_encode($file_options),
“folderPath” => “/docs”
);
echo ‘<pre>’;
print_r($post_data);
echo ‘</pre>’;
$ch = curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_URL, $post_url);
@curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
// Return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch); //Log the response from HubSpot as needed.
print_r($response);
$image_url = json_decode($response ,true);
$url = $image_url[‘objects’][0][‘url’];
print_r($url);
curl_close($ch);