All Projects → synapticloop → backblaze-b2-java-api

synapticloop / backblaze-b2-java-api

Licence: MIT license
Java API for the fabulous backblaze B2 API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to backblaze-b2-java-api

B2.NET
.NET library for Backblaze's B2 Cloud Storage
Stars: ✭ 63 (+384.62%)
Mutual labels:  backblaze, backblaze-api, backblaze-storage-service
j4ts
Core Java APIs for TypeScript / JavaScript / JSweet
Stars: ✭ 92 (+607.69%)
Mutual labels:  java-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (+161.54%)
Mutual labels:  java-api
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (+423.08%)
Mutual labels:  java-api
compare-utils
Compares of Java Collections and Objects (of different classes) made easy
Stars: ✭ 15 (+15.38%)
Mutual labels:  java-api
polynimbus
Multi-cloud infrastructure inventory and management tool, supporting AWS, Google Cloud, Azure, Oracle Cloud, Rackspace Cloud, Hetzner Cloud, Alibaba Cloud, e24cloud.com, Linode, Cloudflare, GoDaddy and Backblaze B2.
Stars: ✭ 70 (+438.46%)
Mutual labels:  backblaze
Bintray Release
A helper for releasing from gradle up to bintray
Stars: ✭ 1,878 (+14346.15%)
Mutual labels:  bintray
radiobrowser4j
RadioBrowser Java API library
Stars: ✭ 30 (+130.77%)
Mutual labels:  java-api
testlink-java-api
TestLink Java API
Stars: ✭ 62 (+376.92%)
Mutual labels:  java-api
b2-sdk-php
SDK for Backblaze's B2 storage service.
Stars: ✭ 75 (+476.92%)
Mutual labels:  backblaze
wbp4j
Simple Java Api for 微博图床,使用简单的api即可完成上传图片
Stars: ✭ 48 (+269.23%)
Mutual labels:  java-api
travels-java-api
An API for travel management. It is built with Java, Spring Boot, and Spring Framework. A toy-project to serve as a theoretical basis for the Medium series of articles I wrote about Java+Spring.
Stars: ✭ 139 (+969.23%)
Mutual labels:  java-api
tiff-java
Tagged Image File Format Java Library
Stars: ✭ 65 (+400%)
Mutual labels:  java-api
japi
Used to generate a beautiful API Java document
Stars: ✭ 103 (+692.31%)
Mutual labels:  java-api
MilightAPI
A java API for MiLight light bulbs. Other brands of light bulbs are also compatible, for instance EasyBulb, LimitlessLED, etc.
Stars: ✭ 28 (+115.38%)
Mutual labels:  java-api
google-search-results-java
Google Search Results JAVA API via SerpApi
Stars: ✭ 18 (+38.46%)
Mutual labels:  java-api
Useful Java Links
A list of useful Java frameworks, libraries, software and hello worlds examples
Stars: ✭ 5,126 (+39330.77%)
Mutual labels:  java-api
yahoo-weather-java-api
A Java API for the yahoo weather service
Stars: ✭ 26 (+100%)
Mutual labels:  java-api
multi-library-bintray
A demo project to illustrate Bintray release configuration of a project which contains several modules.
Stars: ✭ 27 (+107.69%)
Mutual labels:  bintray
backblaze
Backblaze.Agent is a high-performance .NET Core implementation of the Backblaze B2 Cloud Storage API.
Stars: ✭ 32 (+146.15%)
Mutual labels:  backblaze

Build Status Download GitHub Release

backblaze-b2-java-api top

A java api for the truly excellent backblaze b2 storage service

Table of Contents top

Just looking for a GUI?

We thoroughly recommend either cyberduck or mountainduck which includes this code for the awesome BackBlaze storage service.

Usage top



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 to the private bucket
			b2ApiClient.uploadFile(createPrivateBucket.getBucketId(), "myfile.txt", new File("/tmp/temporary-file.txt"));

		} catch(B2ApiException | IOException ex) {
			ex.printStackTrace();
		}
	}

}

see B2ApiClient.java for a complete list of relatively self-explanatory methods.

// create a new B2ApiClient
B2ApiClient()

// authenticate the client
authenticate(String, String)

// create a bucket
createBucket(String, BucketType)

// delete bucket
deleteBucket(String)

// delete a version of a file
deleteFileVersion(String, String)

// download the full file by id, returning a variety of objects
downloadFileById(String)
downloadFileByIdToFile(String, File)
downloadFileByIdToStream(String)

// download the full file by name, returning a variety of objects
downloadFileByName(String, String)
downloadFileByNameToFile(String, String, File)
downloadFileByNameToStream(String, String)

// download partial content of a file by id, returning a variety of objects
downloadFileRangeById(String, long, long)
downloadFileRangeByIdToFile(String, File, long, long)
downloadFileRangeByIdToStream(String, long, long)

// download partial content of a file by name, returning a variety of objects
downloadFileRangeByName(String, String, long, long)
downloadFileRangeByNameToFile(String, String, File, long, long)
downloadFileRangeByNameToStream(String, String, long, long)

// retrieve information on a file
getFileInfo(String)

// return the headers associated with a file
headFileById(String)

// list all of the buckets
listBuckets()

// list file names
listFileNames(String)
listFileNames(String, String, Integer)

// list file versions
listFileVersions(String)
listFileVersions(String, String)
listFileVersions(String, String, String, Integer)

// update the bucket type (private or public)
updateBucket(String, BucketType)

// upload a file
uploadFile(String, String, File)
uploadFile(String, String, File, Map<String, String>)
uploadFile(String, String, File, String)
uploadFile(String, String, File, String, Map<String, String>)


Large File Support top

Large files can range in size from 100MB to 10TB.

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.

startLargeFileUpload(String bucketId, String fileName, String mimeType, Map<String, String> fileInfo)
getUploadPartUrl(String fileId)
uploadLargeFilePart(String fileId, int partNumber, HttpEntity entity, String sha1Checksum)
finishLargeFileUpload(String fileId, String[] partSha1Array)

// you can list the parts that are not yet finished
listUnfinishedLargeFiles(String bucketId, String startFileId, Integer maxFileCount)

Building the Package top

*NIX/Mac OS X top

From the root of the project, simply run

./gradlew build

Windows top

./gradlew.bat build

This will compile and assemble the artefacts into the build/libs/ directory.

Note that this may also run tests (if applicable see the Testing notes)

Running the Tests top

*NIX/Mac OS X top

From the root of the project, simply run

gradle --info test

if you do not have gradle installed, try:

gradlew --info test

Windows top

From the root of the project, simply run

gradle --info test

if you do not have gradle installed, try:

./gradlew.bat --info test

The --info switch will also output logging for the tests

!!IMPORTANT!! WARNING ABOUT RUNNING THE TESTS top

WARNING: These tests make calls against resources (either API calls to a service provider, or consumption of resources from a service provider) which may contribute to your limits, which may lead to a cost.

!!! IMPORTANT !!!

You MUST have the following environment variables set:

export B2_ACCOUNT_ID="your-account-id"
export B2_APPLICATION_KEY="your-application-key"

Logging - slf4j top

slf4j is the logging framework used for this project. In order to set up a logging framework with this project, sample configurations are below:

Log4j top

You will need to include dependencies for this - note that the versions may need to be updated.

Maven

<dependency>
	<groupId>org.apache.logging.log4j</groupId>
	<artifactId>log4j-slf4j-impl</artifactId>
	<version>2.5</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.apache.logging.log4j</groupId>
	<artifactId>log4j-core</artifactId>
	<version>2.5</version>
	<scope>runtime</scope>
</dependency>

Gradle < 2.1

dependencies {
	...
	runtime(group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.5', ext: 'jar')
	runtime(group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5', ext: 'jar')
	...
}

Gradle >= 2.1

dependencies {
	...
	runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
	runtime 'org.apache.logging.log4j:log4j-core:2.5'
	...
}

Setting up the logging:

A sample log4j2.xml is below:

<Configuration status="WARN">
	<Appenders>
		<Console name="Console" target="SYSTEM_OUT">
			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
		</Console>
	</Appenders>
	<Loggers>
		<Root level="trace">
			<AppenderRef ref="Console"/>
		</Root>
	</Loggers>
</Configuration>

Artefact Publishing - Github top

This project publishes artefacts to GitHub

Note that the latest version can be found https://github.com/synapticloop/backblaze-b2-java-api/releases

As such, this is not a repository, but a location to download files from.

Artefact Publishing - Bintray top

This project publishes artefacts to bintray

Note that the latest version can be found https://bintray.com/synapticloop/maven/backblaze-b2-java-api/view

maven setup top

this comes from the jcenter bintray, to set up your repository:

<?xml version="1.0" encoding="UTF-8" ?>
<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'>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>bintray</name>
          <url>http://jcenter.bintray.com</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>bintray-plugins</name>
          <url>http://jcenter.bintray.com</url>
        </pluginRepository>
      </pluginRepositories>
      <id>bintray</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>bintray</activeProfile>
  </activeProfiles>
</settings>

gradle setup top

Repository

repositories {
	maven {
		url  "http://jcenter.bintray.com" 
	}
}

or just

repositories {
	jcenter()
}

Dependencies - Gradle top

dependencies {
	runtime(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '2.3.1', ext: 'jar')

	compile(group: 'synapticloop', name: 'backblaze-b2-java-api', version: '2.3.1', ext: 'jar')
}

or, more simply for versions of gradle greater than 2.1

dependencies {
	runtime 'synapticloop:backblaze-b2-java-api:2.3.1'

	compile 'synapticloop:backblaze-b2-java-api:2.3.1'
}

Dependencies - Maven top

<dependency>
	<groupId>synapticloop</groupId>
	<artifactId>backblaze-b2-java-api</artifactId>
	<version>2.3.1</version>
	<type>jar</type>
</dependency>

Dependencies - Downloads top

You will also need to download the following dependencies:

cobertura dependencies

  • net.sourceforge.cobertura:cobertura:2.1.1: (It may be available on one of: bintray mvn central)

compile dependencies

runtime dependencies

testCompile dependencies

testRuntime dependencies

NOTE: You may need to download any dependencies of the above dependencies in turn (i.e. the transitive dependencies)

License top

The MIT License (MIT)

Copyright (c) 2017 synapticloop

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

--

This README.md file was hand-crafted with care utilising synapticlooptemplar->documentr

--

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].