本文整理汇总了Java中com.qiniu.http.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于com.qiniu.http包,在下文中一共展示了Client类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signRequest
import com.qiniu.http.Client; //导入依赖的package包/类
/**
* 生成HTTP请求签名字符串
*
* @param urlString
* @param body
* @param contentType
* @return
*/
public String signRequest(String urlString, byte[] body, String contentType) {
URI uri = URI.create(urlString);
String path = uri.getRawPath();
String query = uri.getRawQuery();
Mac mac = createMac();
mac.update(StringUtils.utf8Bytes(path));
if (query != null && query.length() != 0) {
mac.update((byte) ('?'));
mac.update(StringUtils.utf8Bytes(query));
}
mac.update((byte) '\n');
if (body != null && body.length > 0 && !StringUtils.isNullOrEmpty(contentType)) {
if (contentType.equals(Client.FormMime)
|| contentType.equals(Client.JsonMime)) {
mac.update(body);
}
}
String digest = UrlSafeBase64.encodeToString(mac.doFinal());
return this.accessKey + ":" + digest;
}
示例2: ResumeUploader
import com.qiniu.http.Client; //导入依赖的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();
}
示例3: put
import com.qiniu.http.Client; //导入依赖的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();
}
示例4: ResumeUploader
import com.qiniu.http.Client; //导入依赖的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];
}
示例5: put
import com.qiniu.http.Client; //导入依赖的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();
}
示例6: FormUploader
import com.qiniu.http.Client; //导入依赖的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;
}
示例7: OperationManager
import com.qiniu.http.Client; //导入依赖的package包/类
public OperationManager(Auth auth) {
this.auth = auth;
this.client = new Client();
}
示例8: post
import com.qiniu.http.Client; //导入依赖的package包/类
private Response post(String url, byte[] data, int offset, int size) throws QiniuException {
return client.post(url, data, offset, size, new StringMap().put("Authorization", "UpToken " + upToken),
Client.DefaultMime);
}
示例9: BucketManager
import com.qiniu.http.Client; //导入依赖的package包/类
public BucketManager(Auth auth) {
this.auth = auth;
client = new Client();
}
示例10: post
import com.qiniu.http.Client; //导入依赖的package包/类
private Response post(String url, byte[] body) throws QiniuException {
StringMap headers = auth.authorization(url, body, Client.FormMime);
return client.post(url, body, headers, Client.FormMime);
}
示例11: UploadManager
import com.qiniu.http.Client; //导入依赖的package包/类
public UploadManager() {
client = new Client();
}
示例12: pfop
import com.qiniu.http.Client; //导入依赖的package包/类
/**
* 触发 空间 文件 的 pfop 操作
*
* @param bucket 空间名
* @param key 文件名
* @param fops fop指令
* @param params notifyURL、force、pipeline 等参数
* @return persistentId
* @throws QiniuException 触发失败异常,包含错误响应等信息
* @link http://developer.qiniu.com/docs/v6/api/reference/fop/pfop/pfop.html
*/
public String pfop(String bucket, String key, String fops, StringMap params) throws QiniuException {
params = params == null ? new StringMap() : params;
params.put("bucket", bucket).put("key", key).put("fops", fops);
byte[] data = StringUtils.utf8Bytes(params.formString());
String url = Config.API_HOST + "/pfop/";
StringMap headers = auth.authorization(url, data, Client.FormMime);
Response response = client.post(url, data, headers, Client.FormMime);
PfopStatus status = response.jsonToObject(PfopStatus.class);
return status.persistentId;
}
示例13: UploadManager
import com.qiniu.http.Client; //导入依赖的package包/类
/**
* 断点上传记录。只针对 文件分块上传。
* 分块上传中,将每一块上传的记录保存下来。上传中断后可在上一次断点记录基础上上传剩余部分。
*
* @param recorder 断点记录者
* @param keyGen 生成文件的断点记录标示,根据生成的标示,可找到断点记录的内容
*/
public UploadManager(Recorder recorder, RecordKeyGenerator keyGen) {
client = new Client();
this.recorder = recorder;
this.keyGen = keyGen;
}