GithubHelp home page GithubHelp logo

dustlight-cn / storage Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 5.0 107 KB

Storage service for Spring Boot, Provides an easy-to-use storage service for the Spring Boot project, including local storage and cloud storage. Spring Boot 储存服务,包括本地储存和云储存(阿里云OSS、腾讯云COS)

Home Page: https://dustlight-cn.github.io/storage

License: Apache License 2.0

Java 100.00%
sotrage springboot tencent-cos tencent-cloud-cos cos aliyun-oss oss

storage's Introduction

Storage

README English | 简体中文

Introductions

Storage is project based on java language development, it provides an easy-to-use storage service for the Spring Boot project, including local storage and cloud storage. This project is under maintenance. Welcome for your issues and pull request. 😀

Build Status GitHub GitHub release (latest by date)

Module

Download

Grab via Maven:

<dependency>
  <groupId>cn.dustlight.storage</groupId>
  <artifactId>storage-core</artifactId>
  <version>0.0.6</version>
</dependency>

Use

Simple use cases with LocalStorage look like this:

package com.example.demo;

import cn.dustlight.storage.core.Permission;
import cn.dustlight.storage.core.StorableObject;
import cn.dustlight.storage.core.Storage;
import cn.dustlight.storage.local.LocalStorage;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;

import java.io.InputStream;
import java.io.OutputStream;

@SpringBootApplication
@Component
public class DemoApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    public void run(ApplicationArguments args) throws Exception {

        Storage storage = LocalStorage.defaultInstance; // Default instance's path is '.'
        StorableObject test = storage.create("test.txt", Permission.PUBLIC); // Create a object with key 'test.txt', with permission 'PUBLIC'

        OutputStream out = test.getOutputStream(); // Get object output stream
        out.write("Hello World!".getBytes()); // Write OutputStream
        out.close();

        InputStream in = test.getInputStream(); // Get object input stream
        byte[] data = new byte[13]; // Read InputStream
        in.read(data);
        in.close();
        String str = new String(data);
        System.out.println(str);

    }
}

Other operations, such as copying, checking for existence, and deleting:

storage.put("text2.txt",test); // Put object to 'test2.txt'.

storage.isExist("text.txt"); // Check object exists or not.

storage.remove("text.txt"); // Delete object

TencentCloudObjectStorage in Tencent Cloud Object Storage provides the URL generated, it can generate the URL for get, put and remove.

See the wiki for full instructions.

Get Help

To report a specific problem or feature request, open a new issue on Github. For questions, suggestions, or anything else, email [email protected].

storage's People

Contributors

hansin1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.