资源简介
多渠道的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
相关资源
- 阿里云产品思维导图
- vue阿里云oss文件的基本操作
- .Net OSS操作代码
- 骑士人才系统阿里云短信接口 支持最
- 阿里云 DATAX mongo数据导入 增强版
- 阿里云灾备
- 阿里云OSS代码
- Multifractal detrended cross-correlation analy
- 阿里云ACP认证题目.txt
- 七牛云存储同步程序七牛云盘.zip
- 15.Aliyun.rar
- 时滞Cohen-Grossberg神经网络p阶矩ψ(
- lp-Nonlinear Measure: A New Approach to Stabil
- Asymptotical and adaptive synchronization of C
- Cohen-Grossberg型BAM神经网络指数稳定性
- Cohen-Grossberg神经网络稳定性分析
- BCS-BEC crossover and quantum phase transition
- The universal “heartbeat” oscilli
- Bifurcation analysis in a delayed fractional C
- Cross-species microsatellites amplification fo
- The Instability of Spiky Steady States for a C
-
Photoinduced Bending Behaviour of Cross-li
n - Strain effect on colossal oxygen ionic conduct
- Hydraulic conductivity determination and leaka
-
thermal conductivity of me
tallic nanofilms: - Impact of surface-bond-order-loss on the phono
- 监视BOSS刷新的时间
- (最新) 阿里云消息 RocketMQ开发手册
- 微信小程序调用uploadFile向七牛云存储
- 阿里云IoT物联网平台-ESP8266 MQTT 1路开
评论
共有 条评论