John Santos
John Santos

Reputation: 525

How to Upload Image/Videos to Google Cloud Storage Using Java

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.

Upvotes: 0

Views: 630

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83048

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.

Upvotes: 1

Related Questions