I am trying to upload a file other than images (like text, pdf or zip etc.) as an asset in usergrid. I have tried both approaches.
The files gets uploaded but when I am debugging the code or checking the file extension in AWS S3 bucket, it always have .jpeg format.
I am attaching three screenshots for this.
First - Usergrid code debugging.
Second - Postman request, with headers detail.
Third - Postman request, with file attachment.
EDIT
Usergrid asset upload response :
{ "action": "post",
"application": "438d5dbb-fa4a-11e5-b62a-080027f0920f",
"params": {}, "path": "/org1app2col1s", "uri": "https://api.bentobox.ws/org1/org1app2/org1app2col1s", "entities": [ { "uuid": "73264555-fa4a-11e5-b62a-080027f0920f", "type": "org1app2col1", "name": "org1app2col1", "created": 1459763337108, "modified": 1459763337108, "address": "shimla", "distance": "485KM", "file-metadata": { "last-modified": 1459927941794, "content-length": 1383, "checksum": "ed66b082f53607bac25c4680bbb95257",
"content-type": "image/jpeg", "etag": "ed66b082f53607bac25c4680bbb95257" }, "metadata": { "path": "/org1app2col1s/73264555-fa4a-11e5-b62a-080027f0920f" } } ], "timestamp": 1459927934034, "duration": 1078925, "organization": "org1", "applicationName": "org1app2" }
It return "content-type": "image/jpeg" even if I upload text file.
Any help would be highly appreciated. THANKS!!!
Are you setting the Accept header when requesting the entity back? If you do, it should return the content type of whatever the accept header is.
And what does the metadata > content-type property look like in the Usergrid entity once it's been created?
application/octet-stream is a catch-all for content types, and therefore probably won't give you what you're expecting back (although why it's being interpreted as jpeg is a mystery to me).
Thanks @Brandon for the reply. There is no problem with the retrieval and Yes I am setting the accept header when I want to get the asset. But when I am uploading a text or pdf file, content type should be application/pdf or text/plain. But In the usergrid asset upload response the content type is "image/jpeg". Please check the question again I've added upload response to it.
Hrmmm very strange. Do you know which version of Usergrid you're using? I wonder if by sending application/octet-stream (without specifying the type directly) it's defaulting to jpeg?
I am using Usergrid 2.1.0, I tried 2.0 too but no luck. Same problem exists in both versions.
Failed to load resource: the server responded with a status of 500 (Internal Server Error) 3 Answers
How to upload an image using chrome RestClient 1 Answer
How i can upload a asset on the BAAS with an API on the BAAS, without curl ? 3 Answers
Not able to download/Retrive asset attachment from usergrid 3 Answers
Not able to download image assets to mobile from a Usergrid folder 1 Answer