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

Commit 65d8c72

Browse files
author
synapticloop
committed
updated documentation
1 parent 03e500a commit 65d8c72

File tree

8 files changed

+307
-105
lines changed

8 files changed

+307
-105
lines changed

README.md

+235-57
Large diffs are not rendered by default.

build.gradle

+17-16
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ plugins {
33
id 'eclipse'
44
id "maven"
55
id "maven-publish"
6-
id 'net.saliman.cobertura' version '2.3.0'
7-
id "com.jfrog.bintray" version "1.6"
6+
id 'net.saliman.cobertura' version '2.3.2'
7+
id "com.jfrog.bintray" version "1.7"
88
id 'co.riiid.gradle' version '0.4.2'
9-
id 'synapticloop.documentr' version '1.3.4'
9+
id 'synapticloop.documentr' version '2.6.1'
10+
id 'com.github.ben-manes.versions' version '0.13.0'
1011
}
1112

1213
group = 'synapticloop'
1314
archivesBaseName = 'backblaze-b2-java-api'
1415
description = """A java api for the truly excellent backblaze b2 storage service"""
1516

16-
version = '2.0.2'
17+
version = '2.1.0'
1718

1819
sourceCompatibility = 1.7
1920
targetCompatibility = 1.7
@@ -27,25 +28,25 @@ repositories {
2728
}
2829

2930
dependencies {
30-
runtime 'org.apache.httpcomponents:httpclient:4.5.1'
31-
runtime 'commons-io:commons-io:2.4'
32-
runtime 'org.json:json:20160212'
31+
runtime 'org.apache.httpcomponents:httpclient:4.5.2'
32+
runtime 'commons-io:commons-io:2.5'
33+
runtime 'org.json:json:20160810'
3334
runtime 'org.slf4j:slf4j-api:1.7.13'
3435

35-
compile 'org.apache.httpcomponents:httpclient:4.5.1'
36-
compile 'commons-io:commons-io:2.4'
37-
compile 'org.json:json:20160212'
36+
compile 'org.apache.httpcomponents:httpclient:4.5.2'
37+
compile 'commons-io:commons-io:2.5'
38+
compile 'org.json:json:20160810'
3839
compile 'org.slf4j:slf4j-api:1.7.13'
3940

4041
testCompile 'junit:junit:4.12'
41-
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
42-
testCompile 'org.apache.logging.log4j:log4j-core:2.5'
43-
testCompile 'org.json:json:20160212'
42+
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl:2.7'
43+
testCompile 'org.apache.logging.log4j:log4j-core:2.7'
44+
testCompile 'org.json:json:20160810'
4445

4546
testRuntime 'junit:junit:4.12'
46-
testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
47-
testRuntime 'org.apache.logging.log4j:log4j-core:2.5'
48-
testRuntime 'org.json:json:20160212'
47+
testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.7'
48+
testRuntime 'org.apache.logging.log4j:log4j-core:2.7'
49+
testRuntime 'org.json:json:20160810'
4950
}
5051

5152
configurations.all {

documentr.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
{ "type":"inbuilt", "value":"project-name" },
1111
{ "type":"inbuilt", "value":"project-description" },
1212

13+
{ "type": "markup", "value": "\n\n# Table of Contents\n\n" },
14+
15+
{ "type": "toc", "value": "2" },
16+
{ "type": "toclinks", "value": "true" },
17+
{ "type": "toplink", "value": " <a name=\"#documentr_top\"></a>" },
18+
{ "type": "tocbacktotop", "value": " <sup><sup>[top](#documentr_top)</sup></sup>" },
19+
1320
{ "type":"file", "value":"src/docs/gui.md" },
1421

15-
{ "type":"file", "value":"src/docs/usage.md" },
22+
{ "type":"file", "value":"src/docs/usage-001.md" },
23+
24+
{ "type":"file", "value":"src/test/java/synapticloop/b2/QuickExampleMain.java" },
25+
26+
{ "type":"file", "value":"src/docs/usage-002.md" },
1627

1728
{ "type":"inbuilt", "value":"gradle-build" },
1829
{ "type":"inbuilt", "value":"gradle-test" },

src/docs/usage-001.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Usage
2+
3+
```
4+
5+

src/docs/usage.md renamed to src/docs/usage-002.md

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
# Usage
21

3-
```
4-
// required imports
5-
import synapticloop.b2.B2ApiClient;
6-
import synapticloop.b2.exception.B2ApiException;
7-
import synapticloop.b2.request.*;
8-
import synapticloop.b2.response.*;
9-
10-
11-
String b2AccountId = ""; // your b2 account ID
12-
String b2ApplicationKey = ""; // your b2 application Key
13-
14-
B2ApiClient b2ApiClient = new B2ApiClient();
15-
b2ApiClient.authorize(b2AccountId, b2ApplicationKey);
16-
17-
// now create a private bucket
18-
B2BucketResponse createPrivateBucket = b2ApiClient.createBucket("super-secret-bucket" , BucketType.ALL_PRIVATE);
19-
20-
// or a public one
21-
B2BucketResponse createPublicBucket = b2ApiClient.createBucket("everyone-has-access" , BucketType.ALL_PUBLIC);
22-
23-
// upload a file
24-
b2ApiClient.uploadFile(createPrivateBucket.getBucketId(), "myfile.txt", new File("/tmp/temporary-file.txt"));
252
```
263
274
see [B2ApiClient.java](https://github.com/synapticloop/backblaze-b2-java-api/blob/master/src/main/java/synapticloop/b2/B2ApiClient.java) for a complete list of relatively self-explanatory methods.
@@ -30,18 +7,15 @@ see [B2ApiClient.java](https://github.com/synapticloop/backblaze-b2-java-api/blo
307
// create a new B2ApiClient
318
B2ApiClient()
329

33-
// authorize the client
34-
authorize(String, String)
10+
// authenticate the client
11+
authenticate(String, String)
3512

3613
// create a bucket
3714
createBucket(String, BucketType)
3815

3916
// delete bucket
4017
deleteBucket(String)
4118

42-
// delete bucket and all containing files
43-
deleteBucketFully(String)
44-
4519
// delete a version of a file
4620
deleteFileVersion(String, String)
4721

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class BaseB2Response {
3434
* Create a new B2 Response object by parsing the passed in String
3535
*
3636
* @param json the Response (in json format)
37-
* @throws B2ApiException if there was an error in the parsing of the reponse
37+
* @throws B2ApiException if there was an error in the parsing of the response
3838
*/
3939
public BaseB2Response(final String json) throws B2ApiException {
4040
this(parse(json));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package synapticloop.b2;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
6+
import synapticloop.b2.exception.B2ApiException;
7+
import synapticloop.b2.response.B2BucketResponse;
8+
9+
public class QuickExampleMain {
10+
11+
public static void main(String[] args) throws B2ApiException, IOException {
12+
String b2AccountId = ""; // your b2 account ID
13+
String b2ApplicationKey = ""; // your b2 application Key
14+
15+
try {
16+
B2ApiClient b2ApiClient = new B2ApiClient();
17+
b2ApiClient.authenticate(b2AccountId, b2ApplicationKey);
18+
19+
// now create a private bucket
20+
B2BucketResponse createPrivateBucket = b2ApiClient.createBucket("super-secret-bucket" , BucketType.allPrivate);
21+
22+
// or a public one
23+
B2BucketResponse createPublicBucket = b2ApiClient.createBucket("everyone-has-access" , BucketType.allPublic);
24+
25+
// upload a file
26+
b2ApiClient.uploadFile(createPrivateBucket.getBucketId(), "myfile.txt", new File("/tmp/temporary-file.txt"));
27+
} catch(B2ApiException | IOException ex) {
28+
ex.printStackTrace();
29+
}
30+
}
31+
32+
}

src/test/java/synapticloop/b2/request/B2DownloadFileRequestTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.io.File;
66
import java.io.FileWriter;
7+
import java.nio.charset.Charset;
78

89
import org.apache.commons.io.IOUtils;
910
import org.apache.http.impl.client.HttpClients;
@@ -64,10 +65,10 @@ public void testDownloadFileBy() throws Exception {
6465
b2FileResponse = B2TestHelper.uploadTemporaryFileToBucket(randomPrivateBucket.getBucketId());
6566

6667
B2DownloadFileResponse b2DownloadFileResponse = new B2DownloadFileByNameRequest(HttpClients.createDefault(), B2TestHelper.getB2AuthorizeAccountResponse(), randomPrivateBucket.getBucketName(), b2FileResponse.getFileName()).getResponse();
67-
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent()));
68+
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent(), Charset.defaultCharset()));
6869

6970
b2DownloadFileResponse = new B2DownloadFileByIdRequest(HttpClients.createDefault(), B2TestHelper.getB2AuthorizeAccountResponse(), b2FileResponse.getFileId()).getResponse();
70-
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent()));
71+
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent(), Charset.defaultCharset()));
7172

7273
B2TestHelper.deleteFile(b2FileResponse.getFileName(), b2FileResponse.getFileId());
7374
B2TestHelper.deleteBucket(randomPrivateBucket.getBucketId());

0 commit comments

Comments
 (0)