0

I'm developing a server in Java which will provide URLs for images that clients uploaded. Basically the Android/iOS will send some kind of data (I still don't know which data would be sent for image and videos) then I'll upload those images/videos to Google Storage and provide URLs which the users (Android/iOS) will be able to stream.

I've just started with Google Storage and I can't find any example of how to upload an image using Java. All examples I found or are deprecated or it's in PHP or it's not clean.

I think I will need to use the JSON client Library but I can't find a good example for this library either.

Please any help will be VERY appreciate.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
John Santos
  • 485
  • 4
  • 18
  • Do you plan to send the images from an App installed on the phones, or from a browser instance (also on the phone)? I guess you mean from an Android App since you refer to java. How are you going to do for iOS? – Renaud Tarnec Nov 26 '16 at 11:38
  • I plan to send just the file input stream from Android/iOS and then use my server (Google APP Engine) to upload the images to Google Storage. After that I'll need to retrieve URLs to send back to Android/iOS which will stream the URL and show to user. – John Santos Nov 26 '16 at 12:48

1 Answers1

1

Based on your answer to my comment above, you could use the method I described in the following Stack Overflow response in order to save the file from your servlet to the Datastore and return the URL:

How to return a file with Google Cloud Endpoints?.

The two differences between your requirements and the method described in this response are:

  • The way the file is created: in your case through a file input stream, as you mentionned
  • The way you return the URL: since you will probably not use Google Endpoints (because of file input stream) you don't need to return the URL in a string wrapper.
Community
  • 1
  • 1
Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121