本文整理了Java中com.qiniu.android.common.Zone
类的一些代码示例,展示了Zone
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zone
类的具体详情如下:
包路径:com.qiniu.android.common.Zone
类名称:Zone
[英]Created by bailong on 15/10/10.
[中]白龙于2010年10月15日创作。
代码示例来源:origin: qiniu/android-sdk
/**
* 上传数据
*
* @param data 上传的数据
* @param key 上传数据保存的文件名
* @param token 上传凭证
* @param complete 上传完成后续处理动作
* @param options 上传数据的可选参数
*/
public void put(final byte[] data, final String key, final String token,
final UpCompletionHandler complete, final UploadOptions options) {
final UpToken decodedToken = UpToken.parse(token);
if (areInvalidArg(key, data, null, token, decodedToken, complete)) {
return;
}
Zone z = config.zone;
z.preQuery(token, new Zone.QueryHandler() {
@Override
public void onSuccess() {
FormUploader.upload(client, config, data, key, decodedToken, complete, options);
}
@Override
public void onFailure(int reason) {
final ResponseInfo info = ResponseInfo.isStatusCodeForBrokenNetwork(reason) ?
ResponseInfo.networkError(reason, decodedToken) :
ResponseInfo.invalidToken("invalid token");
complete.complete(key, info, null);
}
});
}
代码示例来源:origin: qiniu/android-sdk
@Override
public synchronized String upHost(String token, boolean useHttps, String frozenDomain) {
ZoneInfo info = queryByToken(token);
if (info != null) {
return super.upHost(info, useHttps, frozenDomain);
} else {
return null;
}
}
代码示例来源:origin: qiniu/android-sdk
args.params = params;
boolean success = config.zone.preQuery(token.token);
if (!success) {
return ResponseInfo.invalidToken("failed to get up host");
final String upHost = config.zone.upHost(token.token, config.useHttps, null);
Log.d("Qiniu.FormUploader", "sync upload use up host " + upHost);
ResponseInfo info = client.syncMultipartPost(upHost, args, token);
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
Log.d("Qiniu.FormUploader", "sync upload retry first time use up host " + upHostRetry);
info = client.syncMultipartPost(upHostRetry, args, token);
String upHostRetry2 = config.zone.upHost(token.token, config.useHttps, upHostRetry);
Log.d("Qiniu.FormUploader", "sync upload retry second time use up host " + upHostRetry2);
info = client.syncMultipartPost(upHostRetry2, args, token);
if (info.needRetry()) {
config.zone.frozenDomain(upHostRetry2);
代码示例来源:origin: com.qiniu/qiniu-android-sdk
args.params = params;
boolean success = config.zone.preQuery(token.token);
if (!success) {
return ResponseInfo.invalidToken("failed to get up host");
final String upHost = config.zone.upHost(token.token, config.useHttps, null);
Log.d("Qiniu.FormUploader", "sync upload use up host " + upHost);
ResponseInfo info = client.syncMultipartPost(upHost, args, token);
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
Log.d("Qiniu.FormUploader", "sync upload retry first time use up host " + upHostRetry);
info = client.syncMultipartPost(upHostRetry, args, token);
String upHostRetry2 = config.zone.upHost(token.token, config.useHttps, upHostRetry);
Log.d("Qiniu.FormUploader", "sync upload retry second time use up host " + upHostRetry2);
info = client.syncMultipartPost(upHostRetry2, args, token);
if (info.needRetry()) {
config.zone.frozenDomain(upHostRetry2);
代码示例来源:origin: com.qiniu/qiniu-android-sdk
@Override
public synchronized String upHost(String token, boolean useHttps, String frozenDomain) {
ZoneInfo info = queryByToken(token);
if (info != null) {
return super.upHost(info, useHttps, frozenDomain);
} else {
return null;
}
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
/**
* 上传数据
*
* @param data 上传的数据
* @param key 上传数据保存的文件名
* @param token 上传凭证
* @param complete 上传完成后续处理动作
* @param options 上传数据的可选参数
*/
public void put(final byte[] data, final String key, final String token,
final UpCompletionHandler complete, final UploadOptions options) {
final UpToken decodedToken = UpToken.parse(token);
if (areInvalidArg(key, data, null, token, decodedToken, complete)) {
return;
}
Zone z = config.zone;
z.preQuery(token, new Zone.QueryHandler() {
@Override
public void onSuccess() {
FormUploader.upload(client, config, data, key, decodedToken, complete, options);
}
@Override
public void onFailure(int reason) {
final ResponseInfo info = ResponseInfo.isStatusCodeForBrokenNetwork(reason) ?
ResponseInfo.networkError(reason, decodedToken) :
ResponseInfo.invalidToken("invalid token");
complete.complete(key, info, null);
}
});
}
代码示例来源:origin: qiniu/android-sdk
public void run() {
long offset = recoveryFromRecord();
try {
file = new RandomAccessFile(f, "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
completionHandler.complete(key, ResponseInfo.fileError(e, token), null);
return;
}
nextTask(offset, 0, config.zone.upHost(token.token, config.useHttps, null));
}
代码示例来源:origin: qiniu/android-sdk
z.preQuery(token, new Zone.QueryHandler() {
@Override
public void onSuccess() {
代码示例来源:origin: com.qiniu/qiniu-android-sdk
public void run() {
long offset = recoveryFromRecord();
try {
file = new RandomAccessFile(f, "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
completionHandler.complete(key, ResponseInfo.fileError(e, token), null);
return;
}
nextTask(offset, 0, config.zone.upHost(token.token, config.useHttps, null));
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
z.preQuery(token, new Zone.QueryHandler() {
@Override
public void onSuccess() {
代码示例来源:origin: com.qiniu/qiniu-android-sdk
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
if (info.statusCode == 701 && retried < config.retryMax) {
nextTask((offset / Configuration.BLOCK_SIZE) * Configuration.BLOCK_SIZE, retried + 1, upHost);
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
nextTask(offset, retried + 1, upHostRetry);
return;
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
nextTask(offset, retried + 1, upHostRetry);
return;
代码示例来源:origin: qiniu/android-sdk
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
if (info.statusCode == 701 && retried < config.retryMax) {
nextTask((offset / Configuration.BLOCK_SIZE) * Configuration.BLOCK_SIZE, retried + 1, upHost);
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
nextTask(offset, retried + 1, upHostRetry);
return;
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
nextTask(offset, retried + 1, upHostRetry);
return;
代码示例来源:origin: qiniu/android-sdk
args.params = params;
final String upHost = config.zone.upHost(token.token, config.useHttps, null);
Log.d("Qiniu.FormUploader", "upload use up host " + upHost);
CompletionHandler completion = new CompletionHandler() {
代码示例来源:origin: com.qiniu/qiniu-android-sdk
args.params = params;
final String upHost = config.zone.upHost(token.token, config.useHttps, null);
Log.d("Qiniu.FormUploader", "upload use up host " + upHost);
CompletionHandler completion = new CompletionHandler() {
代码示例来源:origin: qiniu/android-sdk
completionHandler.complete(key, info, response);
} else if (info.needRetry()) {
final String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
Log.d("Qiniu.FormUploader", "retry upload first time use up host " + upHostRetry);
CompletionHandler retried = new CompletionHandler() {
代码示例来源:origin: com.qiniu/qiniu-android-sdk
completionHandler.complete(key, info, response);
} else if (info.needRetry()) {
final String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
Log.d("Qiniu.FormUploader", "retry upload first time use up host " + upHostRetry);
CompletionHandler retried = new CompletionHandler() {
代码示例来源:origin: qiniu/android-sdk
@Override
public void complete(ResponseInfo info, JSONObject response) {
if (info.isNetworkBroken() && !AndroidNetwork.isNetWorkReady()) {
options.netReadyHandler.waitReady();
if (!AndroidNetwork.isNetWorkReady()) {
completionHandler.complete(key, info, response);
return;
}
}
if (info.isOK()) {
removeRecord();
options.progressHandler.progress(key, 1.0);
completionHandler.complete(key, info, response);
return;
}
// mkfile ,允许多重试一次
if (info.needRetry() && retried < config.retryMax + 1) {
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
if (upHostRetry != null) {
nextTask(offset, retried + 1, upHostRetry);
return;
}
}
completionHandler.complete(key, info, response);
}
};
代码示例来源:origin: com.qiniu/qiniu-android-sdk
@Override
public void complete(ResponseInfo info, JSONObject response) {
if (info.isNetworkBroken() && !AndroidNetwork.isNetWorkReady()) {
options.netReadyHandler.waitReady();
if (!AndroidNetwork.isNetWorkReady()) {
completionHandler.complete(key, info, response);
return;
}
}
if (info.isOK()) {
removeRecord();
options.progressHandler.progress(key, 1.0);
completionHandler.complete(key, info, response);
return;
}
// mkfile ,允许多重试一次
if (info.needRetry() && retried < config.retryMax + 1) {
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
if (upHostRetry != null) {
nextTask(offset, retried + 1, upHostRetry);
return;
}
}
completionHandler.complete(key, info, response);
}
};
内容来源于网络,如有侵权,请联系作者删除!