Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 669e3d2

Browse files
SynapticloopSynapticloop
authored andcommitted
fixed readme and javadoc
1 parent 2b4681d commit 669e3d2

File tree

6 files changed

+39
-21
lines changed

6 files changed

+39
-21
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ A Java API for the truly excellent backblaze B2 storage
88
String b2AccountId = ""; // your b2 account ID
99
String b2ApplicationKey = ""; // your b2 application Key
1010
11-
B2ApiClient b2ApiClient = new B2ApiClient(b2AccountId, b2ApplicationKey);
11+
B2ApiClient b2ApiClient = new B2ApiClient();
12+
b2ApiClient.authorize(b2AccountId, b2ApplicationKey);
1213
1314
// now create a private bucket
1415
B2BucketResponse createPrivateBucket = b2ApiClient.createBucket("super-secret-bucket" , BucketType.ALL_PRIVATE);

src/main/java/synapticloop/b2/B2ApiClient.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public B2ApiClient() {
7777

7878
/**
7979
* Must authenticate first before API actions are available
80-
* @param client Shared HTTP client
80+
*
81+
* @param client Shared HTTP client
82+
*
8183
* @see #authenticate(String, String)
8284
*/
8385
public B2ApiClient(CloseableHttpClient client) {
@@ -98,18 +100,29 @@ public B2AuthorizeAccountResponse authenticate(String accountId, String applicat
98100
return b2AuthorizeAccountResponse = new B2AuthorizeAccountRequest(client, accountId, applicationKey).getResponse();
99101
}
100102

103+
/**
104+
* Get the download URL for the authorized response
105+
*
106+
* @return the download URL for the authorized response
107+
*/
101108
public String getDownloadUrl() {
102109
return b2AuthorizeAccountResponse.getDownloadUrl();
103110
}
104111

112+
/**
113+
* Get the API url
114+
*
115+
* @return the API URL for backblaze
116+
*/
105117
public String getApiUrl() {
106118
return b2AuthorizeAccountResponse.getApiUrl();
107119
}
108120

109-
/**
110-
* Release all resources from the connection pool.
111-
* @throws IOException
112-
*/
121+
/**
122+
* Release all resources from the connection pool.
123+
*
124+
* @throws IOException if the client could not be closed
125+
*/
113126
public void close() throws IOException {
114127
client.close();
115128
}
@@ -264,6 +277,7 @@ public B2DownloadFileResponse headFileById(String fileId) throws B2ApiException
264277
* @param fileName the name of the file that will be placed in the bucket
265278
* (including any path separators '/')
266279
* @param entity the file content to upload
280+
* @param sha1Checksum the checksum for the file
267281
* @param mimeType the mime type of the file, if null, then the mime type
268282
* will be attempted to be automatically mapped by the backblaze B2 API
269283
* see <a href="https://www.backblaze.com/b2/docs/content-types.html">https://www.backblaze.com/b2/docs/content-types.html</a>
@@ -389,7 +403,7 @@ public B2DeleteFileVersionResponse deleteFileVersion(String fileName, String fil
389403
* @return The hide response
390404
*
391405
* @throws B2ApiException if there was an error hiding the file
392-
*/
406+
*/
393407
public B2HideFileResponse hideFile(String bucketId, String fileName) throws B2ApiException {
394408
return new B2HideFileRequest(client, b2AuthorizeAccountResponse, bucketId, fileName).getResponse();
395409
}

src/main/java/synapticloop/b2/request/B2UploadFileRequest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class B2UploadFileRequest extends BaseB2Request {
6060
* @param fileName the name of the file
6161
* @param file the file to upload
6262
* @param fileInfo the file info map which are passed through as headers prefixed by "X-Bz-Info-"
63+
*
64+
* @throws B2ApiException if there was an error in the request
6365
*/
6466
public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
6567
B2GetUploadUrlResponse b2GetUploadUrlResponse, String fileName, File file, Map<String, String> fileInfo) throws B2ApiException {
@@ -78,6 +80,8 @@ public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountRespons
7880
* @param file the file to upload
7981
* @param mimeType the mimeTyp (optional, will default to 'b2/x-auto' which
8082
* backblaze will attempt to determine automatically)
83+
*
84+
* @throws B2ApiException if there was an error in the request
8185
*/
8286
public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
8387
B2GetUploadUrlResponse b2GetUploadUrlResponse, String fileName, File file, String mimeType) throws B2ApiException {
@@ -94,12 +98,11 @@ public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountRespons
9498
* @param b2GetUploadUrlResponse the upload URL for this request
9599
* @param fileName the name of the file
96100
* @param file the file to upload
101+
*
102+
* @throws B2ApiException if there was an error in the request
97103
*/
98-
public B2UploadFileRequest(CloseableHttpClient client,
99-
B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
100-
B2GetUploadUrlResponse b2GetUploadUrlResponse,
101-
String fileName,
102-
File file) throws B2ApiException {
104+
public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
105+
B2GetUploadUrlResponse b2GetUploadUrlResponse, String fileName, File file) throws B2ApiException {
103106

104107
this(client, b2AuthorizeAccountResponse, b2GetUploadUrlResponse, fileName, file, null, null);
105108
}
@@ -117,13 +120,11 @@ public B2UploadFileRequest(CloseableHttpClient client,
117120
* backblaze will attempt to determine automatically)
118121
* @param fileInfo the file info map which are passed through as headers
119122
* prefixed by "X-Bz-Info-"
123+
*
124+
* @throws B2ApiException if there was an error in the request
120125
*/
121-
public B2UploadFileRequest(CloseableHttpClient client,
122-
B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
123-
B2GetUploadUrlResponse b2GetUploadUrlResponse,
124-
String fileName,
125-
File file,
126-
String mimeType,
126+
public B2UploadFileRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
127+
B2GetUploadUrlResponse b2GetUploadUrlResponse, String fileName, File file, String mimeType,
127128
Map<String, String> fileInfo) throws B2ApiException {
128129

129130
this(client,

src/main/java/synapticloop/b2/request/BaseB2Request.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ protected URI buildUri() throws URISyntaxException {
274274
* To override what headers are set, this should be done in the constructor
275275
* of the base request object.
276276
*
277-
* @param request The http request to set the headers on
277+
* @param request The HTTP request to set the headers on
278+
*
279+
* @throws B2ApiException if there was an error setting the headers
278280
*/
279281
protected void setHeaders(HttpUriRequest request) throws B2ApiException {
280282
for (String headerKey : requestHeaders.keySet()) {

src/main/java/synapticloop/b2/response/B2BucketResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public B2BucketResponse(String json) throws B2ApiException {
6161
* Instantiate a bucket response with the JSON response as a string from
6262
* the API call. This response is then parsed into the relevant fields.
6363
*
64-
* @param JSONObject The pre-parsed jsonObject
64+
* @param response The pre-parsed jsonObject
6565
*
6666
* @throws B2ApiException if there was an error parsing the response
6767
*/

src/main/java/synapticloop/b2/response/BaseB2Response.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public BaseB2Response(final String json) throws B2ApiException {
4141
/**
4242
* Create a new B2 Response with a pre parsed JSONObject response
4343
*
44-
* @param responsem the pre-parsed json object
44+
* @param response the pre-parsed json object
4545
*
4646
* @throws B2ApiException if there was an error in the response
4747
*/

0 commit comments

Comments
 (0)