Backblaze / b2-sdk-java

The official Java SDK for using Backblaze's B2 Storage APIs
Other
94 stars 26 forks source link

Integration into spring boot #73

Open VincentHQL opened 5 years ago

VincentHQL commented 5 years ago

Can it be integrated into Spring boot?

certainmagic commented 5 years ago

Hi Vincent --

I'm not really familiar with Spring Boot. I know it's a java framework. I know b2-sdk-java works for java programs, so I'm pretty sure it will work. And I suspect the devil is in the details. :)

Which particular details are you concerned about? In issue #65, Dominik has pointed out that he can't put the InputStream that's given to a B2ContentSink into a ResponseEntity because the SDK closes the input stream after B2ContentSink.readContent() returns.

I've asked Dominik if he can just ask our SDK for the download url (and, if needed, some credentials) and create a ResponseEntity with that -- either by redirecting, or by opening an InputStream using the url (and maybe credentials) directly using a normal HTTP API.

thanks, ab

certainmagic commented 5 years ago

Hi Vincent --

How is it going? Do you have any further questions?

thanks, ab

VincentHQL commented 5 years ago

Hi I call the HTTP API directly. I recommend providing a temporary key for clients to upload files directly.

browser ---> Web Server ----> temp key browser ---> b2Stor

Browser calls server interface to return zero-time token, browser uploads files directly to B2.

Example:

https://help.aliyun.com/document_detail/31926.html?spm=a2c4g.11186623.6.1267.2c2749e8Zg6n52

certainmagic commented 5 years ago

Hi Vincent --

I'm not sure if you're saying that you gotten it working or whether you think we're missing something you need. I believe that you can do what you want today:

I think the one thing you mentioned that's not currently provided is a way to make a time limit on the upload url's authToken. (We provide the ability to make a download url that expires.)

ps. Remember to configure the CORS rules on the bucket you're uploading to, so that web pages on your site will be able to upload to your bucket.