Free Support Forum - aspose.cloud

How to download image / zip from remote storage


#1

Hello,
My code for download image / zip is as follow.

             $ch = curl_init();
	
	curl_setopt($ch, CURLOPT_URL, 'https://api.aspose.cloud/v4.0/words/storage/file/cw_page1.png');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
	curl_setopt($ch, CURLOPT_VERBOSE, true);  
	
	$headers = array();
	$headers[] = 'Accept: application/json';
	$headers[] = 'Authorization: Bearer <access_token>';
	$headers[] = 'Content-Length: 0';
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	
	$result = curl_exec($ch);
	if (curl_errno($ch)) {
		echo 'Error:' . curl_error($ch);
	}
	else
	{
		$info = curl_getinfo($ch);
		print_r($info);
	}
	curl_close($ch);

Above code is returning 500 error.


#2

@w3nuts

Thanks for your inquiry. Please check the following sample cURL commands for uploading, splitting and downloading the file from Aspose default storage. Hopefully it will help you to accomplish the task. However, if the issue persists, then please share yoru sample source document here. We will look into it and will guide you accordingly.

// First get JSON Web Token
// Get App Key and App SID from https://dashboard.aspose.cloud/
curl -v "https://api.aspose.cloud/connect/token" -X POST -d "grant_type=client_credentials&client_id=[MyAPP_SID]&client_secret=[MyAPP_KEY]" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json"

// cURL example to upload file to Aspose Default Cloud Storage
curl "https://api.aspose.cloud/v4.0/words/storage/file/TOC_Test.docx" -X PUT -H "accept: application/json" -H "Content-Type: multipart/form-data" -T C:/Temp/TOC_Test.docx -H "authorization: Bearer [ACCESS_TOKEN]"

// Split Word Document from Aspose Default Cloud Storage and Save to ZIP file
curl -X PUT "https://api.aspose.cloud/v4.0/words/TOC_Test.docx/split?format=png&zipOutput=true" -H "accept: application/json" -H "authorization: Bearer [Access_Token]"

// Download ZIP file from Aspose Default Cloud Storage
curl -X GET "https://api.aspose.cloud/v4.0/words/storage/file/TOC_Test.png.zip" -H "accept: application/json" -H "authorization: Bearer [Access_Token]" --output C:/Temp/TOC_Test.png.zip