-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from IlyaLisov/dev
Release 0.1.0
- Loading branch information
Showing
15 changed files
with
2,079 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: codecov | ||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "*" ] | ||
|
||
jobs: | ||
codecov: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} | ||
FIREBASE_BUCKET: ${{ secrets.FIREBASE_BUCKET }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
maven- | ||
- run: | | ||
export FIREBASE_SECRET="${FIREBASE_SECRET}" | ||
export FIREBASE_BUCKET="${FIREBASE_BUCKET}" | ||
mvn clean install | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
files: ./target/site/jacoco/jacoco.xml | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: maven-build | ||
on: | ||
pull_request: | ||
branches: [ "*" ] | ||
|
||
jobs: | ||
maven: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} | ||
FIREBASE_BUCKET: ${{ secrets.FIREBASE_BUCKET }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
maven- | ||
- run: | | ||
export FIREBASE_SECRET="${FIREBASE_SECRET}" | ||
export FIREBASE_BUCKET="${FIREBASE_BUCKET}" | ||
mvn clean install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,148 @@ | ||
# storage | ||
Storage library for Java applications. | ||
# Storage | ||
|
||
[](https://github.com/ilyalisov/storage) | ||
[](https://hitsofcode.com/github/ilyalisov/storage/view?branch=master) | ||
[](https://github.com/ilyalisov/storage/actions/workflows/maven-build.yml) | ||
|
||
[](https://codecov.io/gh/IlyaLisov/storage) | ||
|
||
This repository is an open-source Java library for fast and convenient storing | ||
and accessing data in your Java applications. | ||
|
||
Currently, we support MinIO and Firebase. | ||
|
||
## Content: | ||
|
||
* [How to use](#how-to-use) | ||
* [Instantiate a service](#instantiate-a-service) | ||
* [Save file](#save-file) | ||
* [Delete file](#delete-file) | ||
* [If file exists](#check-if-file-exists) | ||
* [Get file](#get-file) | ||
* [How to contribute](#how-to-contribute) | ||
|
||
## How to use | ||
|
||
At first, you need to install this library. | ||
|
||
With Maven add dependency to your `pom.xml`. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>io.github.ilyalisov</groupId> | ||
<artifactId>storage</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
``` | ||
|
||
This library provides simple and convenient usage. | ||
|
||
### Instantiate a service | ||
|
||
You need to create `MinIOStorageService` object and pass login data for MinIO | ||
to the constructor. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
String host = "http://localhost:9000"; | ||
String rootUser = "rootUser"; | ||
String rootPassword = "rootPassword"; | ||
String bucket = "bucket"; | ||
|
||
StorageService storageService = new MinIOStorageServiceImpl( | ||
host, | ||
rootUser, | ||
rootPassword, | ||
bucket | ||
); | ||
} | ||
} | ||
``` | ||
|
||
And for Firebase it is a bit different. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
InputStream inputStream = new ByteArrayInputStream( | ||
System.getenv("FIREBASE_SECRET").getBytes() | ||
); | ||
String bucket = System.getenv("FIREBASE_BUCKET"); | ||
|
||
StorageService storageService = new FirebaseStorageServiceImpl( | ||
inputStream, | ||
bucket | ||
); | ||
} | ||
} | ||
``` | ||
|
||
After, you can call available methods and use library. | ||
|
||
### Save file | ||
|
||
To save file just call method save. It will return path to saved file. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
StorageFile file = new StorageFile( | ||
"fileName", | ||
"text/plain", | ||
new ByteArrayInputStream("...") | ||
); | ||
|
||
Path path = storageService.save(file); | ||
} | ||
} | ||
``` | ||
|
||
### Delete file | ||
|
||
You can delete file by its name, name and path, and you can delete entire folder | ||
by path. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
storageService.delete("file.txt"); | ||
storageService.delete("file.txt", Path.of("folder")); | ||
storageService.delete(Path.of("folder")); | ||
} | ||
} | ||
``` | ||
|
||
### Check if file exists | ||
|
||
You can check whether file exists or not. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
boolean file1 = storageService.exists("file.txt"); | ||
boolean file2 = storageService.delete("file.txt", Path.of("folder")); | ||
} | ||
} | ||
``` | ||
|
||
### Get file | ||
|
||
You can get file from storage by calling corresponding methods. | ||
|
||
```java | ||
public class Main { | ||
public static void main(String[] args) { | ||
Optional<StorageFile> file = storageService.find("file.txt"); | ||
Optional<StorageFile> file2 = storageService.find("file.txt", Path.of("folder")); | ||
List<StorageFile> files = storageService.findAll( | ||
Path.of("folder"), | ||
new Page(0, 10) | ||
); | ||
} | ||
} | ||
``` | ||
|
||
## How to contribute | ||
|
||
See active issues at [issues page](https://github.com/ilyalisov/storage/issues) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
coverage: | ||
status: | ||
patch: false | ||
project: | ||
default: | ||
threshold: 10% |
Oops, something went wrong.