{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • BaaS/Usergrid /
avatar image
1
Question by Ankur Mahajan · Apr 05, 2016 at 07:13 AM · 1.1k Views usergridassetsasset

Upload and retrieve files (other than images) as an asset.

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.

  1. Send file as octal-stream.
  2. Multipart request.

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!!!

asset-1.jpg (101.3 kB)
asset-2.jpg (39.4 kB)
asset-3.jpg (29.9 kB)
Comment
Add comment Show 4
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image brandon@apigee.com ♦ · Apr 05, 2016 at 07:26 PM 0
Link

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

avatar image Ankur Mahajan brandon@apigee.com ♦ · Apr 06, 2016 at 06:10 AM 0
Link

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.

avatar image brandon@apigee.com ♦ · Apr 06, 2016 at 08:25 PM 0
Link

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?

avatar image Ankur Mahajan brandon@apigee.com ♦ · Apr 12, 2016 at 07:19 AM 0
Link

I am using Usergrid 2.1.0, I tried 2.0 too but no luck. Same problem exists in both versions.

Close

0 Answers

  • Sort: 

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges