/// <summary> /// </summary> /// <param name="op"></param> /// <param name="scope"></param> /// <returns></returns> private async Task <CallRet> op(FileHandle op, EntryPath scope) { string url = string.Format("{0}/{1}/{2}", Config.RS_HOST, OPS[(int)op], Base64URLSafe.Encode(scope.URI)); return(await Call(url)); }
private async Task <CallRet> opFetch(FileHandle op, string fromUrl, EntryPath entryPath) { string url = string.Format("{0}/{1}/{2}/to/{3}", Config.PREFETCH_HOST, OPS[(int)op], Base64URLSafe.Encode(fromUrl), Base64URLSafe.Encode(entryPath.URI)); return(await Call(url)); }
/// <summary> /// 请求持久化 /// </summary> /// <param name="entry"></param> /// <param name="fops"></param> /// <param name="notifyURL"></param> /// <returns></returns> public async Task <string> Do(EntryPath entry, string[] fops, Uri notifyURL, string pipleline, int force = 0) { if ((fops.Length < 1) || string.IsNullOrEmpty(entry?.Bucket) || (notifyURL == null) || !notifyURL.IsAbsoluteUri) { throw new Exception("params error"); } StringBuilder sb = new StringBuilder(); sb.Append(fops[0]); for (int i = 1; i < fops.Length; ++i) { sb.Append(";"); sb.Append(fops[i]); } string body = string.Format("bucket={0}&key={1}&fops={2}¬ifyURL={3}&force={4}&pipeline={5}", entry.Bucket, StringEx.ToUrlEncode(entry.Key), StringEx.ToUrlEncode(sb.ToString()), notifyURL.ToString(), force, pipleline); CallRet ret = await 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); } }
/// <summary> /// 删除文件 /// </summary> /// <param name="bucket">七牛云存储空间名称</param> /// <param name="key">需要删除的文件key</param> /// <returns></returns> public async Task <CallRet> Delete(EntryPath scope) { CallRet callRet = await op(FileHandle.DELETE, scope); return(new Entry(callRet)); }
/// <summary> /// 文件信息查看 /// </summary> /// <param name="scope"></param> /// <returns>文件的基本信息,见<see cref="Entry">Entry</see></returns> public async Task <Entry> Stat(EntryPath scope) { CallRet callRet = await op(FileHandle.STAT, scope); return(new Entry(callRet)); }
/// <summary> /// 抓取资源 /// </summary> /// <param name="fromUrl">需要抓取的文件URL</param> /// <param name="entryPath">目标entryPath</param> /// <returns>见<see cref="CallRet">CallRet</see></returns> public async Task <CallRet> Fetch(string fromUrl, EntryPath entryPath) { return(await opFetch(FileHandle.FETCH, fromUrl, entryPath)); }
/// <summary> /// Initializes a new instance of the <see cref="EntryPathPair" /> class. /// </summary> public EntryPathPair(EntryPath src, EntryPath des) { this.src = src; this.dest = des; }
private void _entryPathPair(string bucketSrc, string keySrc, string bucketDest, string keyDest) { this.src = new EntryPath(bucketSrc, keySrc); this.dest = new EntryPath(bucketDest, keyDest); }