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


Java StringMap类代码示例

本文整理汇总了Java中com.qiniu.util.StringMap的典型用法代码示例。如果您正苦于以下问题:Java StringMap类的具体用法?Java StringMap怎么用?Java StringMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringMap类属于com.qiniu.util包,在下文中一共展示了StringMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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