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

Commit d1af7bf

Browse files
author
synapticloop
committed
updated documentation
1 parent b1f55ac commit d1af7bf

6 files changed

Lines changed: 194 additions & 116 deletions

File tree

README.md

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
> A java api for the truly excellent backblaze b2 storage service
88
99

10+
# Just looking for a GUI?
11+
12+
We thoroughly recommend either [cyberduck](https://cyberduck.io/) or [mountainduck](https://mountainduck.io/) which includes this code for the awesome BackBlaze storage service.
1013
# Usage
1114

1215
```
@@ -100,13 +103,26 @@ uploadFile(String, String, File)
100103
uploadFile(String, String, File, Map<String, String>)
101104
uploadFile(String, String, File, String)
102105
uploadFile(String, String, File, String, Map<String, String>)
103-
```
104106
105107
108+
```
109+
106110

107111
## Large File Support
108112

109-
Large file support is currently in 'Sneak Peek' mode, which means that it is not available for public consumption yet...
113+
Large files can range in size from 100MB to 10TB.
114+
115+
Each large file must consist of at least 2 parts, and all of the parts except the last one must be at least 100MB in size. The last part must contain at least one byte.
116+
117+
```
118+
startLargeFileUpload(String bucketId, String fileName, String mimeType, Map<String, String> fileInfo)
119+
getUploadPartUrl(String fileId)
120+
uploadLargeFilePart(String fileId, int partNumber, HttpEntity entity, String sha1Checksum)
121+
finishLargeFileUpload(String fileId, String[] partSha1Array)
122+
123+
// you can list the parts that are not yet finished
124+
listUnfinishedLargeFiles(String bucketId, String startFileId, Integer maxFileCount)
125+
```
110126

111127

112128

@@ -243,43 +259,87 @@ This project publishes artefacts to [GitHib](https://github.com/)
243259
244260
As such, this is not a repository, but a location to download files from.
245261

246-
# Dependency Management Maven
262+
# Artefact Publishing - Bintray
247263

248-
This project publishes artefacts to [Maven Central](https://search.maven.org/)
264+
This project publishes artefacts to [bintray](https://bintray.com/)
249265

250-
> Note that the latest version can be found [mvn central](http://search.maven.org/#artifactdetails|synapticloop|backblaze-b2-java-api|1.3.4|jar)
266+
> Note that the latest version can be found [https://bintray.com/synapticloop/maven/backblaze-b2-java-api/view](https://bintray.com/synapticloop/maven/backblaze-b2-java-api/view)
251267
252268
## maven setup
253269

254-
No setup is required
270+
this comes from the jcenter bintray, to set up your repository:
271+
272+
```
273+
<?xml version="1.0" encoding="UTF-8" ?>
274+
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd' xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
275+
<profiles>
276+
<profile>
277+
<repositories>
278+
<repository>
279+
<snapshots>
280+
<enabled>false</enabled>
281+
</snapshots>
282+
<id>central</id>
283+
<name>bintray</name>
284+
<url>http://jcenter.bintray.com</url>
285+
</repository>
286+
</repositories>
287+
<pluginRepositories>
288+
<pluginRepository>
289+
<snapshots>
290+
<enabled>false</enabled>
291+
</snapshots>
292+
<id>central</id>
293+
<name>bintray-plugins</name>
294+
<url>http://jcenter.bintray.com</url>
295+
</pluginRepository>
296+
</pluginRepositories>
297+
<id>bintray</id>
298+
</profile>
299+
</profiles>
300+
<activeProfiles>
301+
<activeProfile>bintray</activeProfile>
302+
</activeProfiles>
303+
</settings>
304+
```
255305

256306
## gradle setup
257307

258308
Repository
259309

260310
```
261311
repositories {
262-
mavenCentral()
312+
maven {
313+
url "http://jcenter.bintray.com"
314+
}
315+
}
316+
```
317+
318+
or just
319+
320+
```
321+
repositories {
322+
jcenter()
263323
}
264324
```
265325

266326
## Dependencies - Gradle
267327

268328
```
269329
dependencies {
270-
runtime(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '1.3.4', ext: 'jar')
330+
runtime(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '2.0.0', ext: 'jar')
271331
272-
compile(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '1.3.4', ext: 'jar')
332+
compile(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '2.0.0', ext: 'jar')
273333
}
274334
```
275335

276336
or, more simply for versions of gradle greater than 2.1
277337

278338
```
279339
dependencies {
280-
runtime 'synapticloop:backblaze-b2-java-api:1.3.4'
340+
runtime 'synapticloop:backblaze-b2-java-api:2.0.0'
281341
282-
compile 'synapticloop:backblaze-b2-java-api:1.3.4'
342+
compile 'synapticloop:backblaze-b2-java-api:2.0.0'
283343
}
284344
```
285345

@@ -289,7 +349,7 @@ dependencies {
289349
<dependency>
290350
<groupId>synapticloop</groupId>
291351
<artifactId>backblaze-b2-java-api</artifactId>
292-
<version>1.3.4</version>
352+
<version>2.0.0</version>
293353
<type>jar</type>
294354
</dependency>
295355
```

documentr.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
{ "type":"inbuilt", "value":"project-name" },
1111
{ "type":"inbuilt", "value":"project-description" },
1212

13-
{ "type":"template", "value":"src/docs/usage.md.templar" },
13+
{ "type":"file", "value":"src/docs/gui.md" },
14+
15+
{ "type":"file", "value":"src/docs/usage.md" },
1416

1517
{ "type":"inbuilt", "value":"gradle-build" },
1618
{ "type":"inbuilt", "value":"gradle-test" },
@@ -22,7 +24,7 @@
2224

2325
{ "type":"inbuilt", "value":"publishing-github" },
2426

25-
{ "type":"inbuilt", "value":"publishing-maven" },
27+
{ "type":"inbuilt", "value":"publishing-bintray" },
2628

2729
{ "type":"inbuilt", "value":"dependencies" },
2830

src/docs/gui.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Just looking for a GUI?
2+
3+
We thoroughly recommend either [cyberduck](https://cyberduck.io/) or [mountainduck](https://mountainduck.io/) which includes this code for the awesome BackBlaze storage service.

src/docs/usage.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Usage
2+
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"));
25+
```
26+
27+
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.
28+
29+
```
30+
// create a new B2ApiClient
31+
B2ApiClient()
32+
33+
// authorize the client
34+
authorize(String, String)
35+
36+
// create a bucket
37+
createBucket(String, BucketType)
38+
39+
// delete bucket
40+
deleteBucket(String)
41+
42+
// delete bucket and all containing files
43+
deleteBucketFully(String)
44+
45+
// delete a version of a file
46+
deleteFileVersion(String, String)
47+
48+
// download the full file by id, returning a variety of objects
49+
downloadFileById(String)
50+
downloadFileByIdToFile(String, File)
51+
downloadFileByIdToStream(String)
52+
53+
// download the full file by name, returning a variety of objects
54+
downloadFileByName(String, String)
55+
downloadFileByNameToFile(String, String, File)
56+
downloadFileByNameToStream(String, String)
57+
58+
// download partial content of a file by id, returning a variety of objects
59+
downloadFileRangeById(String, long, long)
60+
downloadFileRangeByIdToFile(String, File, long, long)
61+
downloadFileRangeByIdToStream(String, long, long)
62+
63+
// download partial content of a file by name, returning a variety of objects
64+
downloadFileRangeByName(String, String, long, long)
65+
downloadFileRangeByNameToFile(String, String, File, long, long)
66+
downloadFileRangeByNameToStream(String, String, long, long)
67+
68+
// retrieve information on a file
69+
getFileInfo(String)
70+
71+
// return the headers associated with a file
72+
headFileById(String)
73+
74+
// list all of the buckets
75+
listBuckets()
76+
77+
// list file names
78+
listFileNames(String)
79+
listFileNames(String, String, Integer)
80+
81+
// list file versions
82+
listFileVersions(String)
83+
listFileVersions(String, String)
84+
listFileVersions(String, String, String, Integer)
85+
86+
// update the bucket type (private or public)
87+
updateBucket(String, BucketType)
88+
89+
// upload a file
90+
uploadFile(String, String, File)
91+
uploadFile(String, String, File, Map<String, String>)
92+
uploadFile(String, String, File, String)
93+
uploadFile(String, String, File, String, Map<String, String>)
94+
95+
96+
```
97+
98+
99+
## Large File Support
100+
101+
Large files can range in size from 100MB to 10TB.
102+
103+
Each large file must consist of at least 2 parts, and all of the parts except the last one must be at least 100MB in size. The last part must contain at least one byte.
104+
105+
```
106+
startLargeFileUpload(String bucketId, String fileName, String mimeType, Map<String, String> fileInfo)
107+
getUploadPartUrl(String fileId)
108+
uploadLargeFilePart(String fileId, int partNumber, HttpEntity entity, String sha1Checksum)
109+
finishLargeFileUpload(String fileId, String[] partSha1Array)
110+
111+
// you can list the parts that are not yet finished
112+
listUnfinishedLargeFiles(String bucketId, String startFileId, Integer maxFileCount)
113+
```
114+

src/docs/usage.md.templar

Lines changed: 0 additions & 102 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ public B2UploadPartResponse uploadLargeFilePart(String fileId, int partNumber, H
567567
* @param sha1Checksum the checksum for the part
568568
* @return Upload response
569569
* @throws B2ApiException if there was an error uploading the file
570+
* @throws IOException if there was an error communicating with the API service
570571
*/
571572
public B2UploadPartResponse uploadLargeFilePart(B2GetUploadPartUrlResponse b2GetUploadUrlResponse, int partNumber, HttpEntity entity, String sha1Checksum) throws B2ApiException, IOException {
572573
return new B2UploadPartRequest(client, b2AuthorizeAccountResponse, b2GetUploadUrlResponse, partNumber, entity, sha1Checksum).getResponse();

0 commit comments

Comments
 (0)