本文整理汇总了Java中com.qiniu.android.utils.StringMap类的典型用法代码示例。如果您正苦于以下问题:Java StringMap类的具体用法?Java StringMap怎么用?Java StringMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringMap类属于com.qiniu.android.utils包,在下文中一共展示了StringMap类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asyncMultipartPost
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
private void asyncMultipartPost(String url, StringMap fields, ProgressHandler
progressHandler, String fileName, RequestBody file, CompletionHandler
completionHandler, CancellationHandler cancellationHandler) {
if (this.converter != null) {
url = this.converter.convert(url);
}
final MultipartBuilder mb = new MultipartBuilder();
mb.addFormDataPart("file", fileName, file);
fields.forEach(new Consumer() {
public void accept(String key, Object value) {
mb.addFormDataPart(key, value.toString());
}
});
mb.type(MediaType.parse("multipart/form-data"));
RequestBody body = mb.build();
if (progressHandler != null) {
body = new CountingRequestBody(body, progressHandler, cancellationHandler);
}
asyncSend(new Builder().url(url).post(body), null, completionHandler);
}
示例2: copyPolicy
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
private static void copyPolicy(final StringMap policy, StringMap originPolicy, final boolean strict) {
if (originPolicy == null) {
return;
}
originPolicy.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
if (StringUtils.inStringArray(key, deprecatedPolicyFields)) {
throw new IllegalArgumentException(key + " is deprecated!");
}
if (!strict || StringUtils.inStringArray(key, policyFields)) {
policy.put(key, value);
}
}
});
}
示例3: decode
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
public static StringMap decode(String json) {
// CHECKSTYLE:OFF
Type t = new TypeToken<Map<String, Object>>() {
}.getType();
// CHECKSTYLE:ON
Map<String, Object> x = new Gson().fromJson(json, t);
return new StringMap(x);
}
示例4: uploadTokenWithDeadline
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
String uploadTokenWithDeadline(String bucket, String key, long deadline, StringMap policy, boolean strict) {
String scope = bucket;
if (key != null) {
scope = bucket + ":" + key;
}
StringMap x = new StringMap();
copyPolicy(x, policy, strict);
x.put("scope", scope);
x.put("deadline", deadline);
String s = Json.encode(x);
return signWithData(StringUtils.utf8Bytes(s));
}
示例5: asyncPost
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
public void asyncPost(String url, byte[] body, int offset, int size, StringMap headers,
ProgressHandler progressHandler, CompletionHandler completionHandler,
CancellationHandler c) {
RequestBody rbody;
RequestBody rbody2;
if (this.converter != null) {
url = this.converter.convert(url);
}
if (body == null || body.length <= 0) {
rbody = RequestBody.create(null, new byte[0]);
} else {
rbody = RequestBody.create(MediaType.parse("application/octet-stream"), body, offset,
size);
}
if (progressHandler != null) {
rbody2 = new CountingRequestBody(rbody, progressHandler, c);
} else {
rbody2 = rbody;
}
asyncSend(new Builder().url(url).post(rbody2), headers, completionHandler);
}
示例6: ResumeUploader
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
ResumeUploader(Client client, Configuration config, File f, String key, UpToken token, final
UpCompletionHandler completionHandler, UploadOptions options, String recorderKey) {
this.client = client;
this.config = config;
this.f = f;
this.recorderKey = recorderKey;
this.size = (int) f.length();
this.key = key;
this.headers = new StringMap().put("Authorization", "UpToken " + token.token);
this.completionHandler = new UpCompletionHandler() {
public void complete(String key, ResponseInfo info, JSONObject response) {
if (ResumeUploader.this.file != null) {
try {
ResumeUploader.this.file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
completionHandler.complete(key, info, response);
}
};
if (options == null) {
options = UploadOptions.defaultOptions();
}
this.options = options;
this.chunkBuffer = new byte[config.chunkSize];
this.contexts = new String[((int) ((long) (((this.size + Configuration.BLOCK_SIZE) - 1) /
Configuration.BLOCK_SIZE)))];
this.modifyTime = f.lastModified();
this.token = token;
}
示例7: uploadTokenWithDeadline
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
String uploadTokenWithDeadline(String bucket, String key, long deadline, StringMap policy, boolean strict) {
String scope = bucket;
if (key != null) {
scope = bucket + ":" + key;
}
StringMap x = new StringMap();
copyPolicy(x, policy, strict);
x.put("scope", scope);
x.put("deadline", deadline);
String s = new Gson().toJson(x.map());
return signWithData(StringUtils.utf8Bytes(s));
}
示例8: encode
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
public static String encode(StringMap map) {
return new Gson().toJson(map.map());
}
示例9: authorization
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
public StringMap authorization(String url) {
return authorization(url, null, null);
}
示例10: uploadToken
import com.qiniu.android.utils.StringMap; //导入依赖的package包/类
/**
* 生成上传token
*
* @param bucket 空间名
* @param key key,可为 null
* @param expires 有效时长,单位秒
* @param policy 上传策略的其它参数,如 new StringMap().put("endUser", "uid").putNotEmpty("returnBody", "")。
* scope通过 bucket、key间接设置,deadline 通过 expires 间接设置
* @return 生成的上传token
*/
public String uploadToken(String bucket, String key, long expires, StringMap policy) {
return uploadToken(bucket, key, expires, policy, true);
}