本文整理汇总了Java中com.qiniu.util.StringMap类的典型用法代码示例。如果您正苦于以下问题:Java StringMap类的具体用法?Java StringMap怎么用?Java StringMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringMap类属于com.qiniu.util包,在下文中一共展示了StringMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: multipartPost
import com.qiniu.util.StringMap; //导入依赖的package包/类
private Response multipartPost(String url,
StringMap fields,
String name,
String fileName,
RequestBody file,
StringMap headers) throws QiniuException {
final MultipartBuilder mb = new MultipartBuilder();
mb.addFormDataPart(name, fileName, file);
fields.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
mb.addFormDataPart(key, value.toString());
}
});
mb.type(MediaType.parse("multipart/form-data"));
RequestBody body = mb.build();
Request.Builder requestBuilder = new Request.Builder().url(url).post(body);
return send(requestBuilder, headers);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:21,代码来源:Client.java
示例2: ResumeUploader
import com.qiniu.util.StringMap; //导入依赖的package包/类
ResumeUploader(Client client, String upToken, String key, File file,
StringMap params, String mime, Recorder recorder, String recorderKey) {
this.client = client;
this.upToken = upToken;
this.key = key;
this.f = file;
this.size = file.length();
this.params = params;
this.mime = mime == null ? Client.DefaultMime : mime;
this.host = Config.zone.upHost;
long count = (size + Config.BLOCK_SIZE - 1) / Config.BLOCK_SIZE;
this.contexts = new String[(int) count];
this.blockBuffer = new byte[Config.BLOCK_SIZE];
this.recorder = recorder;
this.recorderKey = recorderKey;
this.modifyTime = f.lastModified();
helper = new RecordHelper();
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:19,代码来源:ResumeUploader.java
示例3: filterParam
import com.qiniu.util.StringMap; //导入依赖的package包/类
/**
* 过滤用户自定义参数,只有参数名以<code>x:</code>开头的参数才会被使用
*
* @param params 待过滤的用户自定义参数
* @return 过滤后的用户自定义参数
*/
private static StringMap filterParam(StringMap params) {
final StringMap ret = new StringMap();
if (params == null) {
return ret;
}
params.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
if (value == null) {
return;
}
String val = value.toString();
if (key.startsWith("x:") && !val.equals("")) {
ret.put(key, val);
}
}
});
return ret;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:28,代码来源:UploadManager.java
示例4: put
import com.qiniu.util.StringMap; //导入依赖的package包/类
/**
* 上传文件
*
* @param file 上传的文件对象
* @param key 上传文件保存的文件名
* @param token 上传凭证
* @param mime 指定文件mimetype
* @param checkCrc 是否验证crc32
*/
public Response put(File file, String key, String token, StringMap params,
String mime, boolean checkCrc) throws QiniuException {
checkArgs(key, null, file, token);
if (mime == null) {
mime = Client.DefaultMime;
}
params = filterParam(params);
long size = file.length();
if (size <= Config.PUT_THRESHOLD) {
return new FormUploader(client, token, key, file, params, mime, checkCrc).upload();
}
String recorderKey = key;
if (keyGen != null) {
recorderKey = keyGen.gen(key, file);
}
ResumeUploader uploader = new ResumeUploader(client, token, key, file,
params, mime, recorder, recorderKey);
return uploader.upload();
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:30,代码来源:UploadManager.java
示例5: ResumeUploader
import com.qiniu.util.StringMap; //导入依赖的package包/类
ResumeUploader(
Client client,
String upToken,
String key,
File file,
StringMap params,
String mime
) {
this.client = client;
this.upToken = upToken;
this.key = key;
this.f = file;
this.size = file.length();
this.params = params;
this.mime = mime == null ? Client.DefaultMime : mime;
this.host = Config.UP_HOST;
long count = (size + Config.BLOCK_SIZE - 1) / Config.BLOCK_SIZE;
this.contexts = new String[(int) count];
this.blockBuffer = new byte[Config.BLOCK_SIZE];
}
开发者ID:charsdavy,项目名称:QiNiuGenertorToken,代码行数:21,代码来源:ResumeUploader.java
示例6: put
import com.qiniu.util.StringMap; //导入依赖的package包/类
/**
* 上传文件
*
* @param file 上传的文件对象
* @param key 上传文件保存的文件名
* @param token 上传凭证
* @param mime 指定文件mimetype
* @param checkCrc 是否验证crc32
*/
public Response put(File file, String key, String token, StringMap params,
String mime, boolean checkCrc) throws QiniuException {
checkArgs(key, null, file, token);
if (mime == null) {
mime = Client.DefaultMime;
}
params = filterParam(params);
long size = file.length();
if (size <= Config.PUT_THRESHOLD) {
return new FormUploader(client, token, key, file, params, mime, checkCrc).upload();
}
ResumeUploader uploader = new ResumeUploader(client, token, key, file, params, mime);
return uploader.upload();
}
开发者ID:charsdavy,项目名称:QiNiuGenertorToken,代码行数:25,代码来源:UploadManager.java
示例7: createBucket
import com.qiniu.util.StringMap; //导入依赖的package包/类
@Override
public void createBucket(String bucketName) {
String codedBucketName = UrlSafeBase64.encodeToString(bucketName);
String url = String.format("%s/mkbucketv2/%s", this.qiniuCfg.rsHost(), codedBucketName);
StringMap headers = this.auth.authorization(url);
try {
this.client.post(url, null, headers, "application/x-www-form-urlencoded");
} catch (QiniuException e) {
e.printStackTrace();
}
}
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:12,代码来源:QiniuKodoImpl.java
示例8: deleteBucket
import com.qiniu.util.StringMap; //导入依赖的package包/类
@Override
public void deleteBucket(String bucketName) {
String url = String.format("%s/drop/%s", this.qiniuCfg.rsHost(), bucketName);
StringMap headers = this.auth.authorization(url);
try {
this.client.post(url, null, headers, "application/x-www-form-urlencoded");
} catch (QiniuException e) {
e.printStackTrace();
}
}
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:11,代码来源:QiniuKodoImpl.java
示例9: post
import com.qiniu.util.StringMap; //导入依赖的package包/类
public Response post(String url, StringMap params, StringMap headers) throws QiniuException {
final FormEncodingBuilder f = new FormEncodingBuilder();
params.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
f.add(key, value.toString());
}
});
return post(url, f.build(), headers);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:11,代码来源:Client.java
示例10: send
import com.qiniu.util.StringMap; //导入依赖的package包/类
public Response send(final Request.Builder requestBuilder, StringMap headers) throws QiniuException {
if (headers != null) {
headers.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
requestBuilder.header(key, value.toString());
}
});
}
requestBuilder.header("User-Agent", userAgent());
long start = System.currentTimeMillis();
com.squareup.okhttp.Response res = null;
Response r;
double duration = (System.currentTimeMillis() - start) / 1000.0;
IpTag tag = new IpTag();
try {
res = httpClient.newCall(requestBuilder.tag(tag).build()).execute();
} catch (IOException e) {
e.printStackTrace();
throw new QiniuException(e);
}
r = Response.create(res, tag.ip, duration);
if (r.statusCode >= 300) {
throw new QiniuException(r);
}
return r;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:30,代码来源:Client.java
示例11: jsonToMap
import com.qiniu.util.StringMap; //导入依赖的package包/类
public StringMap jsonToMap() throws QiniuException {
if (!isJson()) {
return null;
}
String b = bodyString();
return Json.decode(b);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:8,代码来源:Response.java
示例12: FormUploader
import com.qiniu.util.StringMap; //导入依赖的package包/类
private FormUploader(Client client, String upToken, String key, byte[] data, File file, StringMap params,
String mime, boolean checkCrc) {
this.client = client;
token = upToken;
this.key = key;
this.file = file;
this.data = data;
this.params = params;
this.mime = mime;
this.checkCrc = checkCrc;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:12,代码来源:FormUploader.java
示例13: upload
import com.qiniu.util.StringMap; //导入依赖的package包/类
Response upload() throws QiniuException {
buildParams();
if (data != null) {
return client.multipartPost(Config.zone.upHost, params, "file", fileName, data, mime, new StringMap());
}
return client.multipartPost(Config.zone.upHost, params, "file", fileName, file, mime, new StringMap());
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:8,代码来源:FormUploader.java
示例14: upload
import com.qiniu.util.StringMap; //导入依赖的package包/类
Response upload() throws QiniuException {
buildParams();
if (data != null) {
return client.multipartPost(Config.UP_HOST, params, "file", fileName, data, mime, new StringMap());
}
return client.multipartPost(Config.UP_HOST, params, "file", fileName, file, mime, new StringMap());
}
开发者ID:charsdavy,项目名称:QiNiuGenertorToken,代码行数:8,代码来源:FormUploader.java
示例15: uploadToken
import com.qiniu.util.StringMap; //导入依赖的package包/类
@Override
public String uploadToken(String bucket, String key, long expires,
StringMap policy, boolean strict) {
if (expires == -1)
expires = Long.parseLong(CONFIG.getConf(bucket,
QiniuConfig.UPLOAD_EXPIRE, "3600"));
return AUTH.uploadToken(bucket, key, expires, policy, strict);
}
开发者ID:dzh,项目名称:jframe,代码行数:9,代码来源:QiniuServiceImpl.java
示例16: getUpToken
import com.qiniu.util.StringMap; //导入依赖的package包/类
public static String getUpToken() {
return auth.uploadToken(bucket, null, 3600, new StringMap().put("insertOnly", 1));
}
开发者ID:Exrick,项目名称:xmall,代码行数:4,代码来源:QiniuUtil.java
示例17: getUpToken
import com.qiniu.util.StringMap; //导入依赖的package包/类
private String getUpToken() {
return auth.uploadToken(this.bucketName, (String) null, 3600, new StringMap().putNotEmpty("returnBody",
"{\"key\": $(key), \"hash\": $(etag), \"width\": $(imageInfo.width), \"height\": $(imageInfo.height)}"));
}
开发者ID:fku233,项目名称:MBLive,代码行数:5,代码来源:QiNiuKit.java
示例18: getUpToken
import com.qiniu.util.StringMap; //导入依赖的package包/类
private String getUpToken() {
return auth.uploadToken("spring-abc", null, 3600, new StringMap().putNotEmpty("returnBody",
"{\"key\": $(key), \"hash\": $(etag), \"width\": $(imageInfo.width), \"height\": $(imageInfo.height)}"));
}
开发者ID:zh-h,项目名称:spring-abc,代码行数:5,代码来源:Qiniu.java
示例19: uploadResource
import com.qiniu.util.StringMap; //导入依赖的package包/类
/**
* 上传资源的最主要方法
* 参数依次的含义: 点播云空间名(对应portal-->点播空间左上角的名字),失效时间,上传文件类型(参考文档),要上传的文件路径(最好用绝对路径)
* StringMap (params参数)可以put进 key, crc32, x:vod, accept, xvod 这些值进去
*/
public Map<String, Object> uploadResource(String hub, int deadline, String type, String path, Map<String, Object> params) {
if (type == null || type.length() <= 0) {
type = "video";
}
UptokenRet uptokenRet = getVodUptokenV2(hub, deadline, type);
// 判空,能否获取token
if (uptokenRet == null) {
System.err.println("cann't get vod uptoken");
return null;
}
Configuration cf = new Configuration(Zone.autoZone());
// 创建上传对象
UploadManager uploadManager = new UploadManager(cf);
Map<String, Object> ret = new HashMap<String, Object>();
try {
// key 参数为空,则用uptokenRet里的key
String k = uptokenRet.getKey();
if (params.containsKey("key")) {
k = params.get("key").toString();
params.remove("key");
}
boolean checkCrc=false;
if (params.containsKey("crc32")){
checkCrc=(Boolean) params.get("crc32");
params.remove("crc32");
}
// 调用put方法上传
StringMap qparams=new StringMap();
qparams.putAll(params);
Response res=uploadManager.put(path,k,uptokenRet.getUptoken(),qparams,null,checkCrc);
// 打印返回的信息
System.out.println(res.bodyString());
StringMap retMap = res.jsonToMap();
ret.put("code", res.statusCode);
ret.put("hash", retMap.get("hash"));
ret.put("key", retMap.get("key"));
} catch (QiniuException e) {
Response r = e.response;
// 请求失败时,返回错误码,由客户自己根据错误码,在前端显示相应的提示信息
ret.put("code", r.statusCode);
ret.put("msg", r.toString()); // 错误信息
System.err.printf("upload file error:%s",e.toString());
}
return ret;
}
开发者ID:qiniu-jedi,项目名称:jedi-java-sdk,代码行数:61,代码来源:UploadRes.java
示例20: get
import com.qiniu.util.StringMap; //导入依赖的package包/类
public Response get(String url) throws QiniuException {
return get(url, new StringMap());
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:4,代码来源:Client.java
注:本文中的com.qiniu.util.StringMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论