Hi Aspose,
I want to upload an XLS file through the /storage/file
API. My call appears to work in that I get a HTTP 200 back and the file appears in my storage area. However when I download the file to check, it looks like the raw multi-part content from the PUT request.
Programmatic post:
PUT https://api.aspose.cloud/v1.1/storage/file?path=%2Fsimple-template.xls&appSID=xxxx&signature=xxxx
Accept: application/json
Authorization: Bearer xxxx
Content-Type: multipart/form-data; boundary="e721db7d-2f00-444c-a87b-9407ce9c4143"
--e721db7d-2f00-444c-a87b-9407ce9c4143
Content-Disposition: form-data; name=File; filename="/simple-template.xls"; filename*=utf-8''%2Fsimple-template.xls
Content-Type: application/vnd.ms-excel
(file content follows)
The URL is the same as the ‘try it’ example here: Aspose.Platform Cloud - API References
Uploading a file directly into ‘My Storage’ works fine.
Please advise.
Thanks,
Rhys
@rhyswatkin
Thank you for contacting Aspose Support.
We provide two ways to authenticate Aspose REST APIs:
- OAuth 2.0
- URL Signing
PUT https://api.aspose.cloud/v1.1/storage/file?path=%2Fsimple-template.xls&appSID=xxxx&signature=xxxx
Accept: application/json
Authorization: Bearer xxxx
Content-Type: multipart/form-data; boundary="e721db7d-2f00-444c-a87b-9407ce9c4143"
In the given request you are using both authentication methods in the API request instead of one. You are passing App SID
and Signature
parameters in API URL and unnecessary Authorization header.
We recommend our users to use OAuth 2.0 authentication as it is more convenient to use. In the following Postman example the first API is getting Access Token and the second API is Uploading file to Aspose Cloud Storage.
The following cURL example is Uploading File using URL Signing method:
curl -v https://api.aspose.cloud/v1.1/storage/file?path=testfile.txt&appsid=xxxx&signature=xxxx \
-X PUT \
-T testfile.txt \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json"
Hopefully, these examples have made things clear. If there is still any confusion please feel free to contact us.
Hi @sohail.aspose,
Thanks for this. I have been using OAuth2 and signing together for all the other requests I made, and got no problems. Unfortunately, I have run out of the 50 free credits So I can’t currently test this with OAuth2 only.
All the best,
Rhys
@rhyswatkin
Please confirm are your issue regarding uploading file to Aspose Cloud Storage has been fixed with above examples? Please contact us if there are any problems.
As I explained in my previous reply I have exhausted the 50 free credits and have no way to test this presently.
@rhyswatkin
Please note, since Aspose.Cells Cloud 19.9, we have introduced storage APIs as part of Aspose.Cells Cloud API. Now there is no need to use Aspose.Storage Cloud API for storage operation. Please find the sample cURL code for file download from cloud storage. Please feel free to contact us for any question or concern.
// First get JSON Web Token
// Get App Key and App SID from https://dashboard.aspose.cloud/
curl "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=[APP_SID]&client_secret=[APP_KEY]" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
//Download file from cloud storage
curl -X GET "https://api.aspose.cloud/v3.0/cells/storage/file/Test.xlsx"
-H "accept: application/json"
-H "authorization: Bearer [Access_TOken]"
-H "x-aspose-client: Containerize.Swagger"
--output C:/Temp/Test_cells.xlsx
Furthermore, now Free Trial plan has 150 free monthly credit limit instead of 50.