use of com.mendmix.cos.CUploadResult in project jeesuite-libs by vakinge.
the class QiniuProvider method upload.
@Override
public CUploadResult upload(CUploadObject object) {
String fileKey = object.getFileKey();
String bucketName = buildBucketName(object.getBucketName());
try {
Response res = null;
String upToken = getUpToken(bucketName);
if (object.getFile() != null) {
res = uploadManager.put(object.getFile(), fileKey, upToken);
} else if (object.getBytes() != null) {
res = uploadManager.put(object.getBytes(), fileKey, upToken);
} else if (object.getInputStream() != null) {
res = uploadManager.put(object.getInputStream(), fileKey, upToken, null, object.getMimeType());
} else {
throw new IllegalArgumentException("upload object is NULL");
}
if (res.isOK()) {
return new CUploadResult(fileKey, getFullPath(object.getBucketName(), fileKey), null);
}
} catch (QiniuException e) {
processQiniuException(object.getFileKey(), e);
}
return null;
}
Aggregations