本文整理汇总了Java中com.qiniu.android.storage.UpCompletionHandler类的典型用法代码示例。如果您正苦于以下问题:Java UpCompletionHandler类的具体用法?Java UpCompletionHandler怎么用?Java UpCompletionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UpCompletionHandler类属于com.qiniu.android.storage包,在下文中一共展示了UpCompletionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadFile
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
/**
*
*
* */
public void uploadFile(String token, File file, UpCompletionHandler handler) {
// data =<File对象、或 文件路径、或 字节数组>
// String key =<指定七牛服务上的文件名,或 null >;
// String token =<从服务端SDK获取 >;
// new UpCompletionHandler() {
// @Override
// public void complete(String key, ResponseInfo info, JSONObject res) {
// //res包含hash、key等信息,具体字段取决于上传策略的设置
// if (info.isOK()) {
// Log.i("qiniu", "Upload Success");
// } else {
// Log.i("qiniu", "Upload Fail");
// //如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
// }
// Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
// }
// }
uploadManager.put(file, null, token, handler, null);
}
示例2: uploadphoto
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
public void uploadphoto(File file) {
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
ImgPath = BuildConfig.QiniuBase+ res.getString("key");
delegate.setmImgAdd(ImgPath);
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}
示例3: upload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的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);
}
示例4: updateAvatarToQiniu
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的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);
}
示例5: upload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的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);
}
示例6: upload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的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);
}
示例7: imgUpload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
/**
* 通过七牛上传文件
*/
private void imgUpload() {
mViewModel.upLoad(new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info,
JSONObject response) {
if (info.isOK()) {
httpCoachInfo();
} else {
dismissProgressDialog();
Logger.e("imgUpload", info.error);
UIHelper.shortToast(info.error);
}
}
});
}
示例8: imgUpload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
/**
* 通过七牛上传图片
*/
private void imgUpload() {
mViewModel.upLoad(new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info,
JSONObject response) {
if (info.isOK()) {
httpUserInfo();
} else {
dismissProgressDialog();
Logger.e("imgUpload", info.error);
UIHelper.shortToast(info.error);
}
}
});
}
示例9: imgUpload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
/**
* 通过七牛上传图片
*/
private void imgUpload() {
mViewModel.upLoad(new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info,
JSONObject response) {
if (info.isOK()) {
httpCoachInfo();
} else {
dismissProgressDialog();
Logger.e("imgUpload", info.error);
UIHelper.shortToast(info.error);
}
}
});
}
示例10: doInBackground
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
@Override
protected String doInBackground() {
uploadManager.put(file, null, token,
new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
try {
if (info.statusCode == 200) {
// 上传图片返回key值
callback.onSuccess(file, JsonUtils.getString("key", response));
} else {
callback.onError(info.statusCode);
}
} catch (Exception e) {
e.printStackTrace();
callback.onError(1);
}
}
}, null);
return null;
}
示例11: uploadPortrait
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的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);
}
示例12: uploadphoto
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
public void uploadphoto(File file) {
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
String photoName = res.getString("key");
ArrayList<String> data = new ArrayList<>();
data.add(BuildConfig.QiniuBase + photoName);
delegate.setData(data);
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}
示例13: uploadphoto
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
public void uploadphoto(File file) {
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
String photoName = res.getString("key");
// ArrayList<String> data = new ArrayList<>();
// data.add(photoName);
PicPath = BuildConfig.QiniuBase+photoName;
delegate.setmImgPic(photoName);
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}
示例14: uploadPhoto
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
public void uploadPhoto(File file, final int type) {
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
if (type == 0) {
ImgPath = BuildConfig.QiniuBase + res.getString("key");
delegate.setImgAdd(ImgPath);
} else if (type == 1) {
pics.add(BuildConfig.QiniuBase + res.getString("key"));
delegate.setData(pics);
}
// } else if (type == 1) {
// pics.add(BuildConfig.QiniuBase + res.getString("key"));
// delegate.setData(pics);
// }
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}
示例15: doUpload
import com.qiniu.android.storage.UpCompletionHandler; //导入依赖的package包/类
public void doUpload(final ArrayList<String> files, int postion) {
if (postion >= files.size()) {
return;
}
String path = files.get(postion);
File file = BitmapUtil.saveBitmapFile(BitmapUtil.getBitmap(path), path);
if (StringUtils.isNotEmpty(token)) {
UpCompletionHandler handler = new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject res) {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
Log.i("qiniu", "Upload Success");
try {
// if (type == 0) {
// String img = res.getString("key");
pics.add(BuildConfig.QiniuBase + res.getString("key"));
delegate.setData(pics);
imgPosition++;
doUpload(files, imgPosition);
// delegate.setImgAdd(ImgPath);
// } else if (type == 1) {
// delegate.setData(pics);
// }
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.i("qiniu", "Upload Fail");
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
}
Log.i("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}
};
QiniuUpload.getInstance().uploadFile(token, file, handler);
}
}