-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from qiniu/develop
Release v6.1.5
- Loading branch information
Showing
3 changed files
with
136 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Qiniu.Auth; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Qiniu.RS; | ||
using Qiniu.RPC; | ||
using Qiniu.Conf; | ||
using Qiniu.Util; | ||
using Newtonsoft.Json; | ||
|
||
namespace Qiniu.PFOP | ||
{ | ||
public class Mkzip | ||
{ | ||
|
||
/// <summary> | ||
/// 多文件压缩存储为用户提供了批量文件的压缩存储功能 | ||
/// POST /pfop/ HTTP/1.1 | ||
/// Host: api.qiniu.com | ||
/// Content-Type: application/x-www-form-urlencoded | ||
/// Authorization: <AccessToken> | ||
/// bucket = <bucket> | ||
/// mkzip/<mode> | ||
/// /url/<Base64EncodedURL> | ||
/// /alias/<Base64EncodedAlias> | ||
/// /url/<Base64EncodedURL> | ||
/// ... | ||
/// </summary> | ||
public String doMkzip(String bucket, String existKey, String newFileName, String[] urls, string pipeline) | ||
{ | ||
if (bucket == null || string.IsNullOrEmpty(existKey) || string.IsNullOrEmpty(newFileName) || urls.Length < 0 || pipeline == null) | ||
{ | ||
throw new Exception("params error"); | ||
} | ||
String entryURI = bucket + ":" + newFileName; | ||
String urlString = ""; | ||
for (int i = 0; i < urls.Length; i++) | ||
{ | ||
String urlEntry = "/url/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(urls[i]); | ||
urlString += urlEntry; | ||
} | ||
String fop = System.Web.HttpUtility.UrlEncode("mkzip/1" + urlString + "|saveas/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(entryURI)); | ||
|
||
string body = string.Format("bucket={0}&key={1}&fops={2}&pipeline={3}", bucket, existKey, fop, pipeline); | ||
|
||
System.Text.Encoding curEncoding = System.Text.Encoding.UTF8; | ||
|
||
QiniuAuthClient authClient = new QiniuAuthClient(); | ||
CallRet ret = authClient.CallWithBinary(Config.API_HOST + "/pfop/", "application/x-www-form-urlencoded", StreamEx.ToStream(body), body.Length); | ||
if (ret.OK) | ||
{ | ||
try | ||
{ | ||
PersistentId pid = JsonConvert.DeserializeObject<PersistentId>(ret.Response); | ||
return pid.persistentId; | ||
} | ||
catch (Exception e) | ||
{ | ||
throw e; | ||
} | ||
} | ||
else | ||
{ | ||
throw new Exception(ret.Response); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters