本文整理汇总了Java中com.qiniu.android.storage.UploadManager类的典型用法代码示例。如果您正苦于以下问题:Java UploadManager类的具体用法?Java UploadManager怎么用?Java UploadManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UploadManager类属于com.qiniu.android.storage包,在下文中一共展示了UploadManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upLoadFile
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private void upLoadFile(String filePath, MessageInfo message) {
try {
Configuration config = new Configuration.Builder().useHttps(true).build();
// 实例化一个上传的实例
UploadManager uploadManager = new UploadManager(config);
if (mMyUpCompletionHandler == null) {
mMyUpCompletionHandler = new MyUpCompletionHandler();
}
String key = message.getMsgId();
mMyUpCompletionHandler.putCacheMessage(key, message);
uploadManager.put(filePath, key,
XmppInfo.getInstance().getQiniuToken(),
mMyUpCompletionHandler,
new com.qiniu.android.storage.UploadOptions(null, null, false,
mUpProgressHandler, null));
} catch (Exception e) {
e.printStackTrace();
} catch (OutOfMemoryError error) {
error.printStackTrace();
}
}
示例2: upload
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private void upload(String uploadToken, File avatarFile) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
final String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
otherLogin(fileKey); // 新用户登录
}
}
}, null);
}
示例3: updateAvatarToQiniu
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private void updateAvatarToQiniu(File avatarFile) {
UploadManager uploadManager = new UploadManager();
// 指定七牛服务上的文件名
final String genKey = AppUtility.generateUUID();
Logger.d(genKey);
String token = QiniuHelper.getUpToken();
uploadManager.put(avatarFile, genKey, token,
new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
// res 包含hash、key等信息,具体字段取决于上传策略的设置。
Logger.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
updateAvatarKey(genKey);
}
}, null);
}
示例4: upload
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private void upload(String uploadToken, final File avatarFile, final int type) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
Logger.d(fileKey);
if (type == 0) {//修改头像
updateAvatarKey(fileKey, avatarFile);
} else if (type == 1) {//修改背景墙
updateBackGroud(fileKey, avatarFile);
}
}
}
}, null);
}
示例5: upload
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private void upload(String uploadToken, File avatarFile) {
if (this.uploadManager == null) {
this.uploadManager = new UploadManager();
}
String uploadFilKey = AppUtility.generateUUID();
this.uploadManager.put(avatarFile, uploadFilKey, uploadToken, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
if (info.isOK()) {
String fileKey = response.optString("key");
Logger.d(fileKey);
updateAvatarKey(fileKey);
}
}
}, null);
}
示例6: uploadPortrait
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
/**
* 上传头像
*/
private void uploadPortrait() {
if(mKeyToken == null) {
ToastUtils.showMessage(getApplicationContext(), R.string.set_portrait_fail);
return;
}
UploadManager uploadManager = new UploadManager();
File file = new File(Environment.getExternalStorageDirectory()
+ "/" + IMAGE_FILE_NAME);
uploadManager.put(file, mKeyToken.getKey(),
mKeyToken.getToken(), new UpCompletionHandler() {
@Override
public void complete(String fileName, ResponseInfo responseInfo,
JSONObject jsonObject) {
mPortraitURL = Constants.UPLOADFILE_PRE + fileName;
if (responseInfo.isOK()) {
//上传成功,更新用户头像
mUserService.setPortrait(mHandler, String.valueOf(App.currentUser.getId()), mPortraitURL);
} else {
ToastUtils.showMessage(getApplicationContext(),
R.string.set_portrait_fail);
ProgressDialogUtils.dismiss();
}
}
}, null);
}
示例7: upload
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public static rx.Observable<PhotoInfo> upload(String prefix, File file) {
UploadManager uploadManager = getUploadManagerInstance();
String today = Times.formatDateToString(new Date(), "yyyy-MM-dd");
String extName = getExtName(file.getName(), '.');
String key = prefix + "/" + today + UUIDs.randomUUID(4) + extName;
// @formatter:off
return ApiFactory.getSingleton().getUploadToken(Keys.UPLOAD_IMAGE_KEY).flatMap(tokenData -> {
final String token = tokenData.token;
Log.e(TAG, "token:" + token);
return rx.Observable.create(new rx.Observable.OnSubscribe<PhotoInfo>() {
@Override
public void call(Subscriber<? super PhotoInfo> subscriber) {
uploadManager.put(file, key, token, (resultKey, info, res) -> {
Log.d("RxQiniu", info.toString() + "res---" + res);
String url = AppConfig.QINIU_HOST + "/" + resultKey;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
PhotoInfo photoInfo = new PhotoInfo();
photoInfo.url = url;
photoInfo.height = options.outHeight;
photoInfo.width = options.outWidth;
subscriber.onNext(photoInfo);
subscriber.onCompleted();
}, null);
}
});
}).subscribeOn(Schedulers.io());
// @formatter:off
}
示例8: upToQiNiu
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public void upToQiNiu() throws Exception{
PutPolicy policy = new PutPolicy("shutuier",System.currentTimeMillis()+3600,1);
String token = policy.token(null);
Log.e(TAG,"uptoken is " + token);
File f = new File(filePath);
if(f.exists()) {
UploadManager manager = new UploadManager();
manager.put(f,null,token,upHandler,null);
}else {
throw new FileNotFoundException("file not found for path " + filePath);
}
}
示例9: getUploadManager
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public static UploadManager getUploadManager() {
return uploadInstance;
}
示例10: getUpManagerByZone
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private static UploadManager getUpManagerByZone() {
com.qiniu.android.storage.Configuration config = new com.qiniu.android.storage.Configuration.Builder().zone(getZone()).build();
return new UploadManager(config);
}
示例11: QiNiuUtil
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public QiNiuUtil() {
uploadManager = new UploadManager();
}
示例12: uploadImgTask
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private uploadImgTask() {
uploadManager = new UploadManager();
mOSSKey = "";
}
示例13: onAppCreate
import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
@Override
protected void onAppCreate(Context ctx) {
super.onAppCreate(ctx);
mUploadManager = new UploadManager();
}