本文整理匯總了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;
}