资源简介
多渠道的oss文件上传代码,支持阿里云,腾讯云,七牛多渠道,

代码片段和文件信息
/*
*
* * Copyright (C) 2018 Wanghaobin<463540703@qq.com>
*
* * AG-Enterprise 企业版源码
* * 郑重声明:
* * 如果你从其他途径获取到,请告知老A传播人,奖励1000。
* * 老A将追究授予人和传播人的法律责任!
*
* * This program is free software; you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation; either version 2 of the License or
* * (at your option) any later version.
*
* * This program is distributed in the hope that it will be useful
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
*
* * You should have received a copy of the GNU General Public License along
* * with this program; if not write to the Free Software Foundation Inc.
* * 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA.
*
*/
package com.github.wxiaoqi.oss.cloud;
import com.aliyun.oss.OSSClient;
import com.github.wxiaoqi.config.baseException;
import com.github.wxiaoqi.config.CloudStorageConfig;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
* 阿里云存储
* @author ace
*/
public class AliyunCloudStorageService extends CloudStorageService {
private OSSClient client;
public AliyunCloudStorageService(CloudStorageConfig config){
this.config = config;
//初始化
init();
}
private void init(){
client = new OSSClient(config.getAliyunEndPoint() config.getAliyunAccessKeyId()
config.getAliyunAccessKeySecret());
}
@Override
public String upload(byte[] data String path) {
return upload(new ByteArrayInputStream(data) path);
}
@Override
public String upload(InputStream inputStream String path) {
try {
client.putobject(config.getAliyunBucketName() path inputStream);
} catch (Exception e){
throw new baseException(“上传文件失败,请检查配置信息“);
}
return config.getAliyunDomain() + “/“ + path;
}
@Override
public String uploadSuffix(byte[] data String suffix) {
return upload(data getPath(config.getAliyunPrefix() suffix));
}
@Override
public String uploadSuffix(InputStream inputStream String suffix) {
return upload(inputStream getPath(config.getAliyunPrefix() suffix));
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-23 16:45 Oss\
目录 0 2018-08-23 16:45 Oss\oss\
目录 0 2018-08-23 16:45 Oss\oss\cloud\
文件 2630 2018-08-20 17:00 Oss\oss\cloud\AliyunCloudStorageService.java
文件 2983 2018-08-20 17:00 Oss\oss\cloud\CloudStorageService.java
文件 1947 2018-08-20 17:00 Oss\oss\cloud\OSSFactory.java
文件 3599 2018-08-20 17:00 Oss\oss\cloud\QcloudCloudStorageService.java
文件 3207 2018-08-20 17:00 Oss\oss\cloud\QiniuCloudStorageService.java
目录 0 2018-08-23 16:45 Oss\oss\config\
文件 930 2018-08-23 16:15 Oss\oss\config\ba
文件 647 2018-08-23 16:15 Oss\oss\config\ba
文件 6502 2018-08-23 16:15 Oss\oss\config\CloudStorageConfig.java
文件 661 2018-08-23 16:15 Oss\oss\config\ob
目录 0 2018-08-23 16:45 Oss\oss\constants\
文件 1388 2018-08-20 17:00 Oss\oss\constants\OSSConstant.java
目录 0 2018-08-23 16:45 Oss\oss\controller\
文件 2249 2018-08-23 16:15 Oss\oss\controller\OssController.java
- 上一篇:txt2pajek2.0
- 下一篇:面试需要了解的东西.docx
相关资源
- 云平台-阿里云详细介绍
- ucosII源代码 2.9版本全 Micrium-uCOS-II-V
- 四川省移动通信公司BOSS项目集中式数
- 四川移动BOSS集中式数据备份系统建设
- Impact of bond order loss on surface and nanos
- The Existence and Stability of Nontrivial St
- Ross-Konno手术后左心室流出道梗阻
- Sb Pollution in the Soil Moss and Sediments of
- Genome doubling and chromosome elimination wit
- crossfilter tutorial
- 论文研究-基于AMBA AXI总线的Crossbar互联
- 爱立信lte OSS批量操作详解
- OSS图片上传 swift
- 概率论基础教程_M.ROSS
- 阿里云DDNS
- 2019阿里云峰会北京分会场资料-互联网
- 中国移动BOSS系统接口规范代理接入
- Molecular identification polymorphism and asso
- Acute effects of TGFβ1 on neuronal excita
- POSS杂化膜表面微裂纹自愈合性研究
- 2019阿里云峰会北京分会场资料-数字政
- ross统计随机过程第二版
- ESP8266使用MQTT协议连接阿里云
- 丹佛斯Danfoss-FC302操作手册
- 阿里云体系架构介绍-PPT版.pptx
- 腾讯云、阿里云服务器零基础建立、
- 阿里云高性能计算在制造业的应用.
- 基于多任务卷积网络(MTCNN)和Cente
- 随机过程英文第二版-Sheldon M.Ross-加
- 阿里云短信服务demo源码
评论
共有 条评论