当前位置:网站首页>Alibaba OSS object storage service

Alibaba OSS object storage service

2022-06-24 14:25:00 Knowing is knowing

 Alibaba cloud object storage service (Object Storage Service, abbreviation OSS)

 Refer to Ali OSS Object storage services quick start documentation :
1. Introduce dependencies 
<dependency>
    <groupId>com.aliyun.oss</groupId>
    <artifactId>aliyun-sdk-oss</artifactId>
    <version>3.10.2</version>
</dependency>

2.OSS Console create storage space 
 Uploading files (Object) To OSS Before , You need to create a storage space for storing files (Bucket3. Upload files to by streaming upload OSS
 See product documentation 

4. Stream download from OSS Download the file 
 See product documentation 

5. Transfer object 、 Parse object  
① Put the object parse by JSON Upload 
Dog dog = new Dog(" Xiao Huang ", 2);
String jsonStr = JSON.toJSONString(dog);
ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(jsonStr.getBytes()));

② download JSON and parse As object 
OSSObject ossObject = ossClient.getObject(bucketName, objectName);
InputStream content = ossObject.getObjectContent();
if (content != null) {
    
    Dog dog = JSON.parseObject(content, Dog.class);
    System.out.println(dog.getName() + "-" + dog.getAge());
    content.close();
}
原网站

版权声明
本文为[Knowing is knowing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241250343474.html

随机推荐