本文整理汇总了Java中com.qiniu.storage.BucketManager类的典型用法代码示例。如果您正苦于以下问题:Java BucketManager类的具体用法?Java BucketManager怎么用?Java BucketManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BucketManager类属于com.qiniu.storage包,在下文中一共展示了BucketManager类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configUploadEnv
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 配置文件上传环境
*/
public boolean configUploadEnv(String zone, String bucket) {
if (!checkNet()) {
Platform.runLater(() -> {
Dialogs.showError(Values.NET_ERROR);
System.exit(0);
});
return false;
}
logger.info("config file upload environment");
// 构造一个带指定Zone对象的配置类
Configuration configuration = new Configuration(QiniuApplication.zone.get(zone));
// 生成上传凭证,然后准备上传
String localTempDir = Paths.get(QiniuApplication.workDir, bucket).toString();
try {
FileRecorder fileRecorder = new FileRecorder(localTempDir);
QiniuApplication.uploadManager = new UploadManager(configuration, fileRecorder);
} catch (IOException e1) {
logger.error("load local temp directory failed, can't use file recorder");
QiniuApplication.uploadManager = new UploadManager(configuration);
}
QiniuApplication.configuration = configuration;
QiniuApplication.bucketManager = new BucketManager(QiniuApplication.auth, configuration);
return true;
}
开发者ID:zhazhapan,项目名称:qiniu,代码行数:28,代码来源:QiConfiger.java
示例2: getAllImage
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 返回仓库下所有图片的URL
* @return URL集合
*/
public static List<String> getAllImage() throws MythException{
loadProperties();
BucketManager bucketManager = new BucketManager(auth, config);
List<String> imageList = new ArrayList<>();//文件列表
try {
//调用listFiles方法列举指定空间的指定文件
//参数一:bucket 空间名
//参数二:prefix 文件名前缀
//参数三:marker 上一次获取文件列表时返回的 marker
//参数四:limit 每次迭代的长度限制,最大1000,推荐值 100
//参数五:delimiter 指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
FileListing fileListing = bucketManager.listFiles(bucketName, null, null, 100, null);
FileInfo[] items = fileListing.items;
for (FileInfo fileInfo : items) {
imageList.add(qiniuLink +fileInfo.key);
}
} catch (IOException e) {
throw new ConnectionException(GET_IMAGE_LIST_EXCEPTION,e,QiNiuCloud.class);
}
return imageList;
}
开发者ID:Kuangcp,项目名称:JavaToolKit,代码行数:26,代码来源:QiNiuCloud.java
示例3: afterPropertiesSet
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
Configuration cfg = new Configuration(Zone.zone0());
cfg.connectTimeout=5000;
cfg.responseTimeout=5000;
cfg.writeTimeout=2000;
auth = Auth.create(accessKey, secretKey);
uploadManager = new UploadManager(cfg);
// 实例化一个BucketManager对象
bucketManager = new BucketManager(auth, cfg);
new Thread() {
public void run() {
deleteBlockingDequeImage();
}
}.start();
}
开发者ID:ggj2010,项目名称:javabase,代码行数:18,代码来源:QiNiuUtil.java
示例4: deleteByList
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 删除图片
* https://developer.qiniu.com/kodo/sdk/java#rs-batch-delete
* 每次只能删除小于1000条数据
*
* @param list
*/
public void deleteByList(List<String> list) {
try {
if (list == null) return;
log.info("待删除图片大小:{}", list.size());
String[] keyList = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
keyList[i] = list.get(i).replace(domain, "");
}
BucketManager.Batch batchOperations = new BucketManager.Batch();
batchOperations.delete(bucketName, keyList);
Response response = bucketManager.batch(batchOperations);
BatchStatus[] batchStatusList = response.jsonToObject(BatchStatus[].class);
/*for (int k = 0; k < keyList.length; k++) {
BatchStatus status = batchStatusList[k];
if (status.code == 200) {
// log.info("delete success");
} else {
log.error("删除失败", status.toString());
}
}*/
} catch (QiniuException e) {
log.error("七牛上传 response:" + e.getLocalizedMessage());
}
}
开发者ID:ggj2010,项目名称:javabase,代码行数:32,代码来源:QiNiuUtil.java
示例5: fileList
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 列举指定前缀的文件
*
* @param prefix
*/
public void fileList(String prefix) {
//每次迭代的长度限制,最大1000,推荐值 1000
int limit = 1000;
//指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
String delimiter = "";
//列举空间文件列表
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucketName, prefix, limit, delimiter);
while (fileListIterator.hasNext()) {
//处理获取的file list结果
FileInfo[] items = fileListIterator.next();
for (FileInfo item : items) {
log.info(item.key);
}
}
}
开发者ID:ggj2010,项目名称:javabase,代码行数:21,代码来源:QiNiuUtil.java
示例6: QiniuProvider
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
public QiniuProvider(String urlprefix, String bucketName, String accessKey, String secretKey,boolean isPrivate) {
Validate.notBlank(bucketName, "[bucketName] not defined");
Validate.notBlank(accessKey, "[accessKey] not defined");
Validate.notBlank(secretKey, "[secretKey] not defined");
Validate.notBlank(urlprefix, "[urlprefix] not defined");
this.urlprefix = urlprefix.endsWith(DIR_SPLITER) ? urlprefix : urlprefix + DIR_SPLITER;
this.bucketName = bucketName;
auth = Auth.create(accessKey, secretKey);
Zone z = Zone.autoZone();
Configuration c = new Configuration(z);
uploadManager = new UploadManager(c);
bucketManager = new BucketManager(auth,c);
this.isPrivate = isPrivate;
}
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:19,代码来源:QiniuProvider.java
示例7: deleteFile
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 删除七牛云上的文件
*
* @param fileName
* 文件名
*/
public void deleteFile(String fileName) {
// 实例化一个BucketManager对象
BucketManager bucketManager = new BucketManager(auth);
try {
// 调用delete方法移动文件
bucketManager.delete(bucketname, fileName);
logger.info("文件" + fileName + "已删除");
} catch (QiniuException e) {
// 捕获异常信息
Response r = e.response;
logger.info(r.toString());
}
}
开发者ID:MarchMachao,项目名称:ZHFS-WEB,代码行数:20,代码来源:QniuHelper.java
示例8: listFileOfBucket
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 获取空间文件列表,并映射到FileInfo
*/
public void listFileOfBucket() {
MainWindowController main = MainWindowController.getInstance();
// 列举空间文件列表
String bucket = main.bucketChoiceCombo.getValue();
BucketManager.FileListIterator iterator = QiniuApplication.bucketManager.createFileListIterator(bucket, "",
Values.BUCKET_LIST_LIMIT_SIZE, "");
ArrayList<FileInfo> files = new ArrayList<FileInfo>();
logger.info("get file list of bucket: " + bucket);
QiniuApplication.totalLength = 0;
QiniuApplication.totalSize = 0;
// 处理获取的file list结果
while (iterator.hasNext()) {
com.qiniu.storage.model.FileInfo[] items = iterator.next();
for (com.qiniu.storage.model.FileInfo item : items) {
QiniuApplication.totalLength++;
QiniuApplication.totalSize += item.fsize;
// 将七牛的时间单位(100纳秒)转换成毫秒,然后转换成时间
String time = Formatter.timeStampToString(item.putTime / 10000);
String size = Formatter.formatSize(item.fsize);
FileInfo file = new FileInfo(item.key, item.mimeType, size, time);
files.add(file);
logger.info("file name: " + item.key + ", file type: " + item.mimeType + ", file size: " + size
+ ", file time: " + time);
}
}
QiniuApplication.data = FXCollections.observableArrayList(files);
}
开发者ID:zhazhapan,项目名称:qiniu,代码行数:31,代码来源:QiManager.java
示例9: load
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
public void load() {
cfg = new Configuration(Zone.autoZone());
auth = Auth.create(Config.getInstance().getQiniuAccessKey(),
Config.getInstance().getQiniuSecretKey());
bucketManager = new BucketManager(auth, cfg);
uploadManager = new UploadManager(cfg);
uploadData = new HashMap<>();
uploadPool = Executors.newFixedThreadPool(10);
}
开发者ID:cmlanche,项目名称:javafx-qiniu-tinypng-client,代码行数:11,代码来源:QiniuManager.java
示例10: QiniuProvider
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
public QiniuProvider(String urlprefix, String bucketName, String accessKey, String secretKey) {
this.urlprefix = urlprefix.endsWith(DIR_SPLITER) ? urlprefix : urlprefix + DIR_SPLITER;
this.bucketName = bucketName;
auth = Auth.create(accessKey, secretKey);
Zone z = Zone.autoZone();
Configuration c = new Configuration(z);
uploadManager = new UploadManager(c);
bucketManager = new BucketManager(auth, c);
}
开发者ID:warlock-china,项目名称:azeroth,代码行数:11,代码来源:QiniuProvider.java
示例11: deleteFileList
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
public void deleteFileList(String prefix) throws Exception {
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucketName, prefix, 1000, "");
while (fileListIterator.hasNext()) {
//处理获取的file list结果
FileInfo[] items = fileListIterator.next();
List<String> list = new ArrayList<>(items.length);
for (FileInfo item : items) {
list.add(item.key);
}
getDeleteBlockingDeque().put(list);
}
}
开发者ID:ggj2010,项目名称:javabase,代码行数:13,代码来源:QiNiuUtil.java
示例12: getFileList
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
public List<FileInfo> getFileList(String bucket, String prefix){
List<FileInfo> list = new ArrayList<FileInfo>();
BucketManager bucketManager = new BucketManager(auth);
BucketManager.FileListIterator it = bucketManager.createFileListIterator(bucket, "");
while (it.hasNext()) {
FileInfo[] items = it.next();
if(items != null){
for (int i = 0; i < items.length; i++) {
list.add(items[i]);
}
}
}
return list;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:15,代码来源:QNBucketMgmr.java
示例13: QiniuBucket
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
QiniuBucket(String bucket, String domain, Auth auth, BucketManager bm){
this.bucket = bucket;
this.auth = auth;
this.bucketManager = bm;
this.domain = domain;
uploadManager = new UploadManager();
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:9,代码来源:QiniuBucket.java
示例14: getFileList
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 获取以prefix命名的文件列表
* @param bucket
* @param prefix
* @return
*/
public List<FileInfo> getFileList(String bucket, String prefix){
List<FileInfo> list = new ArrayList<FileInfo>();
BucketManager bucketManager = new BucketManager(auth);
BucketManager.FileListIterator it = bucketManager.createFileListIterator(bucket, "");
while (it.hasNext()) {
FileInfo[] items = it.next();
if(items != null){
for (int i = 0; i < items.length; i++) {
list.add(items[i]);
}
}
}
return list;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:21,代码来源:QiniuBucket.java
示例15: deleteFiles
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
/**
* 批量删除文件,单次批量请求的文件数量不得超过1000
*/
public void deleteFiles(ObservableList<FileInfo> fileInfos, String bucket) {
if (Checker.isNotEmpty(fileInfos) && new QiConfiger().checkNet()) {
// 生成待删除的文件列表
String[] files = new String[fileInfos.size()];
ArrayList<FileInfo> seletecFileInfos = new ArrayList<FileInfo>();
int i = 0;
for (FileInfo fileInfo : fileInfos) {
files[i++] = fileInfo.getName();
seletecFileInfos.add(fileInfo);
}
try {
BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations();
batchOperations.addDeleteOp(bucket, files);
Response response = QiniuApplication.bucketManager.batch(batchOperations);
BatchStatus[] batchStatusList = response.jsonToObject(BatchStatus[].class);
MainWindowController main = MainWindowController.getInstance();
// 文件列表是否为搜索后结果
boolean sear = Checker.isNotEmpty(main.searchTextField.getText());
ObservableList<FileInfo> currentRes = main.resTable.getItems();
for (i = 0; i < files.length; i++) {
BatchStatus status = batchStatusList[i];
String deleteLog = Formatter.datetimeToString(new Date());
String file = files[i];
if (status.code == 200) {
logger.info("delete file '" + file + "' success");
deleteLog += "\tsuccess\t";
QiniuApplication.data.remove(seletecFileInfos.get(i));
QiniuApplication.totalLength--;
QiniuApplication.totalSize -= Formatter.sizeToLong(seletecFileInfos.get(i).getSize());
if (sear) {
currentRes.remove(seletecFileInfos.get(i));
}
} else {
logger.error("delete file '" + file + "' failed, message: " + status.data.error);
deleteLog += "\tfailed\t";
Dialogs.showError("删除文件:" + file + " 失败");
}
QiniuApplication.deleteLog.append(deleteLog + bucket + "\t" + file + "\r\n");
}
} catch (QiniuException e) {
Dialogs.showException(Values.DELETE_ERROR, e);
}
MainWindowController.getInstance().setBucketCount();
}
}
开发者ID:zhazhapan,项目名称:qiniu,代码行数:49,代码来源:QiManager.java
示例16: QNBucketMgmr
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
private QNBucketMgmr(String ak, String sk){
this.ak = ak;
this.sk = sk;
auth = Auth.create(ak, sk);
bucketManager = new BucketManager(auth);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:7,代码来源:QNBucketMgmr.java
示例17: QiniuSpace
import com.qiniu.storage.BucketManager; //导入依赖的package包/类
private QiniuSpace(String ak, String sk){
this.ak = ak;
this.sk = sk;
auth = Auth.create(ak, sk);
bucketManager = new BucketManager(auth);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:7,代码来源:QiniuSpace.java
注:本文中的com.qiniu.storage.BucketManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论