当前位置: 首页>>代码示例>>Java>>正文


Java UploadManager类代码示例

本文整理汇总了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();
    }

}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:23,代码来源:ChatActivityPresenter.java

示例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);
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:17,代码来源:BindActivity.java

示例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);
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:17,代码来源:PerfectDataActivity.java

示例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);
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:22,代码来源:MyUserFragment.java

示例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);
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:18,代码来源:EditUserDataActivity.java

示例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);
}
 
开发者ID:liuling07,项目名称:QiQuYing,代码行数:29,代码来源:CreateUserInfoActivity.java

示例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
}
 
开发者ID:drakeet,项目名称:Lunei,代码行数:33,代码来源:RxQiniu.java

示例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);
    }
}
 
开发者ID:rantianhua,项目名称:ShuTuier,代码行数:13,代码来源:UploadPicture.java

示例9: getUploadManager

import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public static UploadManager getUploadManager() {
    return uploadInstance;
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:4,代码来源:Functions.java

示例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);
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:5,代码来源:Functions.java

示例11: QiNiuUtil

import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
public QiNiuUtil() {
    uploadManager = new UploadManager();
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:4,代码来源:QiNiuUtil.java

示例12: uploadImgTask

import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
private uploadImgTask() {
    uploadManager = new UploadManager();
    mOSSKey = "";
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:5,代码来源:PublishActivity.java

示例13: onAppCreate

import com.qiniu.android.storage.UploadManager; //导入依赖的package包/类
@Override
protected void onAppCreate(Context ctx) {
    super.onAppCreate(ctx);
    mUploadManager = new UploadManager();
}
 
开发者ID:Jude95,项目名称:Fishing,代码行数:6,代码来源:ImageModel.java


注:本文中的com.qiniu.android.storage.UploadManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。