资源简介
基于阿里云的java网盘 OSS网盘实现_3分.zip
阿里云 saas 对象存储服务 网盘 oss
代码片段和文件信息
package javacloud;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.*;
import javax.swing.JProgressBar;
import javax.swing.ProgressMonitor;
import javax.swing.ProgressMonitorInputStream;
import com.aliyun.openservices.ClientConfiguration;
import com.aliyun.openservices.ClientException;
import com.aliyun.openservices.oss.*;
import com.aliyun.openservices.oss.model.*;
public class CloudManage {
private static final String ACCESS_ID = “CiLeKzg6iBlPHG7U“;
private static final String ACCESS_KEY = “ChozGIJkN1Tsco6H3WscZGWxym7hl8“;
private static final String OSS_ENDPOINT = “http://oss.aliyuncs.com/“;
static OSSClient client;
static String bucketName;
ClientConfiguration config;
static String Downfilepath;
CloudManage(String bucketname)
{
config = new ClientConfiguration();
client = new OSSClient(OSS_ENDPOINT ACCESS_ID ACCESS_KEY config);
bucketName=bucketname;
Downfilepath=new String();
ensureBucket(client bucketName);
}
public static void initCloudManage(String bucketname)
{
new CloudManage(bucketname);
}
// 如果Bucket不存在,则创建它。
private static void ensureBucket(OSSClient client String bucketName)
throws OSSException ClientException{
if (client.isBucketExist(bucketName)){
return;
}
//创建bucket
client.createBucket(bucketName);
}
// 上传文件
public static PutobjectResult uploadFile(String key String filenameJProgressBar progressbar)
throws OSSException ClientException FileNotFoundException {
File file = new File(filename);
objectmetadata objectmeta = new objectmetadata();
objectmeta.setContentLength(file.length());
InputStream input = new FileInputStream(file);
PutobjectResult result=client.putobject(bucketName key input objectmeta);
progressbar.setValue(1);
return result;
}
public static void uploadnullFile(String key String filename) throws FileNotFoundException
{
File file = new File(filename);
objectmetadata objectmeta = new objectmetadata();
objectmeta.setContentLength(file.length());
InputStream input = new FileInputStream(file);
PutobjectResult result=client.putobject(bucketName key input objectmeta);
file.delete();
}
//上传大文件
public static CompleteMultipartUploadResult uploadbigFile(String key String filenameJProgressBar progressbar)
throws Exception {
InitiateMultipartUploadRequest initiateMultipartUploadRequest = new InitiateMultipartUploadRequest(
bucketName key);
InitiateMultipartUploadResult initiateMultipartUploadResult = client
.initiateMultipartUpload(initiateMultipartUploadRequest);
// 设置每块为 5M
final int partSize = 1024 * 1024 * 5;
File partFile = new Fil
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-02-22 21:43 javacloud\
文件 991 2014-02-14 21:11 javacloud\.classpath
文件 385 2014-02-10 17:32 javacloud\.project
目录 0 2014-02-22 21:43 javacloud\.settings\
文件 598 2014-02-10 17:32 javacloud\.settings\org.eclipse.jdt.core.prefs
目录 0 2014-02-18 09:08 javacloud\bin\
目录 0 2014-02-22 21:43 javacloud\bin\javacloud\
文件 6822 2014-02-17 22:02 javacloud\bin\javacloud\CloudManage.class
文件 1872 2014-02-17 22:02 javacloud\bin\javacloud\Databa
文件 819 2014-02-17 22:02 javacloud\bin\javacloud\DownloadThread.class
文件 3867 2014-02-17 22:02 javacloud\bin\javacloud\Filemanage.class
文件 2197 2014-02-17 22:02 javacloud\bin\javacloud\loginfr
文件 763 2014-02-17 22:02 javacloud\bin\javacloud\loginfr
文件 2191 2014-02-17 22:02 javacloud\bin\javacloud\loginfr
文件 690 2014-02-17 22:02 javacloud\bin\javacloud\mainfr
文件 2807 2014-02-17 22:02 javacloud\bin\javacloud\mainfr
文件 3617 2014-02-17 22:02 javacloud\bin\javacloud\mainfr
文件 2962 2014-02-17 22:02 javacloud\bin\javacloud\MD5FileUtil.class
文件 2172 2014-02-17 22:02 javacloud\bin\javacloud\MiddlePan$LabelMouseAction.class
文件 3985 2014-02-17 22:02 javacloud\bin\javacloud\MiddlePan.class
文件 1860 2014-02-17 22:02 javacloud\bin\javacloud\MyRenderer.class
文件 939 2014-02-17 22:02 javacloud\bin\javacloud\MyTree$TreeAction.class
文件 3237 2014-02-17 22:02 javacloud\bin\javacloud\MyTree$TreeMouseAction.class
文件 6264 2014-02-17 22:02 javacloud\bin\javacloud\MyTree.class
文件 2510 2014-02-17 22:02 javacloud\bin\javacloud\Popupmenu$PopupMouseaction.class
文件 1323 2014-02-17 22:02 javacloud\bin\javacloud\Popupmenu.class
文件 1978 2014-02-17 22:02 javacloud\bin\javacloud\registerDialog$ConfacountAction.class
文件 1110 2014-02-17 22:02 javacloud\bin\javacloud\registerDialog$ConfpasswardAction.class
文件 2742 2014-02-17 22:02 javacloud\bin\javacloud\registerDialog$RegisAction.class
文件 2926 2014-02-17 22:02 javacloud\bin\javacloud\registerDialog.class
文件 601 2014-02-17 22:02 javacloud\bin\javacloud\test.class
............此处省略31个文件信息
相关资源
- SpringMVC上传图片文件到 阿里云
- java或android调用阿里云的人脸比对服务
- Java 生成pdf文件加盖公章图片,上传阿
- 阿里云网站原型(axure)
- 2018版阿里云短信API DEMO,已打包必要
- 阿里云物联网套件开发API说明文档I
- 智能家居阿里云服务器后台源码
- 阿里云Apsara Clouder基础技能认证 考题
- java阿里云直播推流播流地址生成工具
- 阿里云root工具
- 阿里云视频点播视频上传+视频点播
- 阿里云短信接口jar包
- 阿里云视频点播上传
- java 连接阿里云的mqtt服务(客户端源
- sbt-launch.jar0.13.11已修改可直接用2019
- Android MQTT Demo(阿里云)
- 阿里云语音服务demo
- 阿里云视频转码java代码
- java 短信验证码基于阿里云
评论
共有 条评论