use of com.jeesuite.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QiniuProvider method getObjectInputStream.
@Override
public InputStream getObjectInputStream(String bucketName, String fileKey) {
bucketName = buildBucketName(bucketName);
String downloadUrl = getDownloadUrl(bucketName, fileKey, 600);
Request request = new Request.Builder().url(downloadUrl).build();
okhttp3.Response re = null;
try {
re = httpClient.newCall(request).execute();
if (re.isSuccessful()) {
return re.body().byteStream();
}
throw new JeesuiteBaseException(re.code(), re.message());
} catch (IOException e) {
throw new JeesuiteBaseException(e.getMessage());
}
}
use of com.jeesuite.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class AliyunProvider method createBucket.
@Override
public void createBucket(String bucketName, boolean isPrivate) {
if (ossClient.doesBucketExist(bucketName)) {
throw new JeesuiteBaseException(406, "bucketName[" + bucketName + "]已存在");
}
CreateBucketRequest request = new CreateBucketRequest(bucketName);
if (isPrivate) {
request.setCannedACL(CannedAccessControlList.Private);
} else {
request.setCannedACL(CannedAccessControlList.PublicRead);
}
ossClient.createBucket(request);
}
use of com.jeesuite.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method getObjectInputStream.
@Override
public InputStream getObjectInputStream(String bucketName, String fileKey) {
try {
String _bucketName = buildBucketName(bucketName);
String _fileKey = resolveFileKey(bucketName, fileKey);
COSObject cosObject = cosclient.getObject(_bucketName, _fileKey);
return cosObject.getObjectContent();
} catch (Exception e) {
throw new JeesuiteBaseException(500, buildMessage(bucketName, e));
}
}
use of com.jeesuite.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method createBucket.
@Override
public void createBucket(String bucketName, boolean isPrivate) {
bucketName = buildBucketName(bucketName);
if (cosclient.doesBucketExist(bucketName)) {
throw new JeesuiteBaseException(406, "bucketName[" + bucketName + "]已存在");
}
CreateBucketRequest request = new CreateBucketRequest(bucketName);
if (isPrivate) {
request.setCannedAcl(CannedAccessControlList.Private);
} else {
request.setCannedAcl(CannedAccessControlList.PublicRead);
}
cosclient.createBucket(request);
}
use of com.jeesuite.common.JeesuiteBaseException in project jeesuite-libs by vakinge.
the class QcloudProvider method getObjectMetadata.
@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
try {
String _bucketName = buildBucketName(bucketName);
String _fileKey = resolveFileKey(bucketName, fileKey);
ObjectMetadata metadata = cosclient.getObjectMetadata(_bucketName, _fileKey);
CObjectMetadata objectMetadata = new CObjectMetadata();
objectMetadata.setCreateTime(metadata.getLastModified());
objectMetadata.setMimeType(metadata.getContentType());
objectMetadata.setFilesize(metadata.getContentLength());
objectMetadata.setHash(metadata.getContentMD5());
objectMetadata.setExpirationTime(metadata.getExpirationTime());
objectMetadata.setCustomMetadatas(metadata.getUserMetadata());
return objectMetadata;
} catch (Exception e) {
throw new JeesuiteBaseException(500, buildMessage(bucketName, e));
}
}
Aggregations