OSS无法下载到本地?为什么
ReOSS无法下载到本地?为什么
各位 这是什么原因啊?是没有权限访问C:\test吗?
-------------------------
ReOSS无法下载到本地?为什么这是javaSDK例子的代码拷贝下来的
public static void main(String[] args) throws IOException,
InterruptedException {
final String localFilePath = 'C:\\test';
final String bucketName = 'user-1';
final String fileKey = 'public-bg9';
ObjectMetadata objectMetadata = client.getObjectMetadata(bucketName,
fileKey);
long partSize = 1024 * 1024 * 5;
long fileLength = objectMetadata.getContentLength();
//随机流可以读也可以写,rw代表“可读写”
RandomAccessFile file = new RandomAccessFile(localFilePath, 'rw');
file.setLength(fileLength);
file.close();
int partCount = calPartCount(fileLength, partSize);
System.out.println('需要下载的文件分块数:' + partCount);
executorService = Executors.newFixedThreadPool(5);
List eTags = Collections
.synchronizedList(new ArrayList());
for (int i = 0; i final long startPos = partSize * i;
final long endPos = partSize
* i
+ (partSize : (fileLength - startPos)) - 1;
executorService.execute(new BlockDownloadThread(startPos, endPos,
localFilePath, bucketName, fileKey, eTags));
}
executorService.shutdown();
while (!executorService.isTerminated()) {
executorService.awaitTermination(5, TimeUnit.SECONDS);
}
if (eTags.size() != partCount) {
throw new IllegalStateException('下载失败,有Part未下载成功。');
}
}
-------------------------
回3楼千鸟的帖子
权限应该没问题吧 你看看
赞0
踩0