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

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
synapticloop committed Dec 4, 2016
1 parent 03e500a commit 65d8c72
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 105 deletions.
292 changes: 235 additions & 57 deletions README.md

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ plugins {
id 'eclipse'
id "maven"
id "maven-publish"
id 'net.saliman.cobertura' version '2.3.0'
id "com.jfrog.bintray" version "1.6"
id 'net.saliman.cobertura' version '2.3.2'
id "com.jfrog.bintray" version "1.7"
id 'co.riiid.gradle' version '0.4.2'
id 'synapticloop.documentr' version '1.3.4'
id 'synapticloop.documentr' version '2.6.1'
id 'com.github.ben-manes.versions' version '0.13.0'
}

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

version = '2.0.2'
version = '2.1.0'

sourceCompatibility = 1.7
targetCompatibility = 1.7
Expand All @@ -27,25 +28,25 @@ repositories {
}

dependencies {
runtime 'org.apache.httpcomponents:httpclient:4.5.1'
runtime 'commons-io:commons-io:2.4'
runtime 'org.json:json:20160212'
runtime 'org.apache.httpcomponents:httpclient:4.5.2'
runtime 'commons-io:commons-io:2.5'
runtime 'org.json:json:20160810'
runtime 'org.slf4j:slf4j-api:1.7.13'

compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'commons-io:commons-io:2.4'
compile 'org.json:json:20160212'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'commons-io:commons-io:2.5'
compile 'org.json:json:20160810'
compile 'org.slf4j:slf4j-api:1.7.13'

testCompile 'junit:junit:4.12'
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
testCompile 'org.apache.logging.log4j:log4j-core:2.5'
testCompile 'org.json:json:20160212'
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl:2.7'
testCompile 'org.apache.logging.log4j:log4j-core:2.7'
testCompile 'org.json:json:20160810'

testRuntime 'junit:junit:4.12'
testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
testRuntime 'org.apache.logging.log4j:log4j-core:2.5'
testRuntime 'org.json:json:20160212'
testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.7'
testRuntime 'org.apache.logging.log4j:log4j-core:2.7'
testRuntime 'org.json:json:20160810'
}

configurations.all {
Expand Down
13 changes: 12 additions & 1 deletion documentr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
{ "type":"inbuilt", "value":"project-name" },
{ "type":"inbuilt", "value":"project-description" },

{ "type": "markup", "value": "\n\n# Table of Contents\n\n" },

{ "type": "toc", "value": "2" },
{ "type": "toclinks", "value": "true" },
{ "type": "toplink", "value": " <a name=\"#documentr_top\"></a>" },
{ "type": "tocbacktotop", "value": " <sup><sup>[top](#documentr_top)</sup></sup>" },

{ "type":"file", "value":"src/docs/gui.md" },

{ "type":"file", "value":"src/docs/usage.md" },
{ "type":"file", "value":"src/docs/usage-001.md" },

{ "type":"file", "value":"src/test/java/synapticloop/b2/QuickExampleMain.java" },

{ "type":"file", "value":"src/docs/usage-002.md" },

{ "type":"inbuilt", "value":"gradle-build" },
{ "type":"inbuilt", "value":"gradle-test" },
Expand Down
5 changes: 5 additions & 0 deletions src/docs/usage-001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Usage

```
30 changes: 2 additions & 28 deletions src/docs/usage.md → src/docs/usage-002.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
# Usage

```
// required imports
import synapticloop.b2.B2ApiClient;
import synapticloop.b2.exception.B2ApiException;
import synapticloop.b2.request.*;
import synapticloop.b2.response.*;
String b2AccountId = ""; // your b2 account ID
String b2ApplicationKey = ""; // your b2 application Key
B2ApiClient b2ApiClient = new B2ApiClient();
b2ApiClient.authorize(b2AccountId, b2ApplicationKey);
// now create a private bucket
B2BucketResponse createPrivateBucket = b2ApiClient.createBucket("super-secret-bucket" , BucketType.ALL_PRIVATE);
// or a public one
B2BucketResponse createPublicBucket = b2ApiClient.createBucket("everyone-has-access" , BucketType.ALL_PUBLIC);
// upload a file
b2ApiClient.uploadFile(createPrivateBucket.getBucketId(), "myfile.txt", new File("/tmp/temporary-file.txt"));
```
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.
Expand All @@ -30,18 +7,15 @@ see [B2ApiClient.java](https://github.com/synapticloop/backblaze-b2-java-api/blo
// create a new B2ApiClient
B2ApiClient()

// authorize the client
authorize(String, String)
// authenticate the client
authenticate(String, String)

// create a bucket
createBucket(String, BucketType)

// delete bucket
deleteBucket(String)

// delete bucket and all containing files
deleteBucketFully(String)
// delete a version of a file
deleteFileVersion(String, String)

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/synapticloop/b2/response/BaseB2Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class BaseB2Response {
* Create a new B2 Response object by parsing the passed in String
*
* @param json the Response (in json format)
* @throws B2ApiException if there was an error in the parsing of the reponse
* @throws B2ApiException if there was an error in the parsing of the response
*/
public BaseB2Response(final String json) throws B2ApiException {
this(parse(json));
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/synapticloop/b2/QuickExampleMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package synapticloop.b2;

import java.io.File;
import java.io.IOException;

import synapticloop.b2.exception.B2ApiException;
import synapticloop.b2.response.B2BucketResponse;

public class QuickExampleMain {

public static void main(String[] args) throws B2ApiException, IOException {
String b2AccountId = ""; // your b2 account ID
String b2ApplicationKey = ""; // your b2 application Key

try {
B2ApiClient b2ApiClient = new B2ApiClient();
b2ApiClient.authenticate(b2AccountId, b2ApplicationKey);

// now create a private bucket
B2BucketResponse createPrivateBucket = b2ApiClient.createBucket("super-secret-bucket" , BucketType.allPrivate);

// or a public one
B2BucketResponse createPublicBucket = b2ApiClient.createBucket("everyone-has-access" , BucketType.allPublic);

// upload a file
b2ApiClient.uploadFile(createPrivateBucket.getBucketId(), "myfile.txt", new File("/tmp/temporary-file.txt"));
} catch(B2ApiException | IOException ex) {
ex.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.io.File;
import java.io.FileWriter;
import java.nio.charset.Charset;

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

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

b2DownloadFileResponse = new B2DownloadFileByIdRequest(HttpClients.createDefault(), B2TestHelper.getB2AuthorizeAccountResponse(), b2FileResponse.getFileId()).getResponse();
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent()));
assertEquals(B2TestHelper.DUMMY_FILE_CONTENT, IOUtils.toString(b2DownloadFileResponse.getContent(), Charset.defaultCharset()));

B2TestHelper.deleteFile(b2FileResponse.getFileName(), b2FileResponse.getFileId());
B2TestHelper.deleteBucket(randomPrivateBucket.getBucketId());
Expand Down

0 comments on commit 65d8c72

Please sign in to comment.