PUT to /storage/file fails to parse multi-part file


#1

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: https://apireference.aspose.cloud/platform/#!/File/PutCreate

Uploading a file directly into ‘My Storage’ works fine.

Please advise.

Thanks,
Rhys


#3

@rhyswatkin

Thank you for contacting Aspose Support.

We provide two ways to authenticate Aspose REST APIs:

  1. OAuth 2.0
  2. 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.


#4

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 :wink: So I can’t currently test this with OAuth2 only.

All the best,
Rhys


#5

@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.


#6

As I explained in my previous reply I have exhausted the 50 free credits and have no way to test this presently.


#7

Acknowledged.