static void Main(string[] args) { //初始化AK,SK Qiniu.Conf.Config.ACCESS_KEY = "Access_Key"; Qiniu.Conf.Config.SECRET_KEY = "Secret_Key"; //设置要转码的空间和key,并且这个key在你空间中存在 String bucket = "Bucket_Name"; String key = "Bucket_key"; //实例化一个entry对象 EntryPath entry = new EntryPath(bucket, key); //设置转码操作参数 String fops = "avthumb/mp4/s/640x360/vb/1.25m"; //设置转码的队列 String pipeline = "yourpipelinename"; //可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。 String urlbase64 = Qiniu.Util.Base64URLSafe.Encode("保存的空间:保存的key"); String pfops = fops + "|saveas/" + urlbase64; //实例化一个fop对象主要进行后续转码操作 Qiniu.RS.Pfop fop = new Qiniu.RS.Pfop(); Uri uri = null; string s = fop.Do(entry, pfops, uri, pipeline, 1); Console.WriteLine(s); Console.ReadLine(); }
public IEnumerable <FileEntry> GetFilesInFolder(EntryPath Path) { foreach (var File in FileEntryTable.Select("directory=?", Path.FullPath)) { yield return(File); } }
public PK3Entry(EntryPath path, ResourceNamespace resourceNamespace, byte[] data) { Path = path; Name = path.Name; Namespace = resourceNamespace; Data = data; }
private CallRet Mkfile(Client client, string key, long fsize) { EntryPath entry = new EntryPath(extra.Bucket, key); string url = string.Format("{0}/rs-mkfile/{1}/fsize/{2}/", Config.UP_HOST, entry.Base64EncodedURI, fsize); if (!string.IsNullOrEmpty(extra.MimeType)) { url += (string.Format("/mimeType/{0}", extra.MimeType.ToBase64URLSafe())); } if (!string.IsNullOrEmpty(extra.CustomMeta)) { url += (string.Format("/meta/{0}", extra.CustomMeta.ToBase64URLSafe())); } if (!string.IsNullOrEmpty(extra.CallbackParams)) { url += (string.Format("/params/{0}", extra.CallbackParams.ToBase64URLSafe())); } int proCount = extra.Progresses.Length; using (Stream body = new MemoryStream()) { for (int i = 0; i < proCount; i++) { byte[] bctx = Encoding.ASCII.GetBytes(extra.Progresses [i].ctx); body.Write(bctx, 0, bctx.Length); if (i != proCount - 1) { body.WriteByte((byte)','); } } body.Seek(0, SeekOrigin.Begin); return(client.CallWithBinary(url, "text/plain", body, body.Length)); } }
/// <summary> /// Pres the fetch. /// </summary> /// <returns><c>true</c>, if fetch was pred, <c>false</c> otherwise.</returns> /// <param name="path">Path.</param> public bool PreFetch(EntryPath path) { string url = Config.PREFETCH_HOST + "/prefetch/" + path.Base64EncodedURI; CallRet ret = Call(url); return(ret.OK); }
/// <summary> /// Creates a new wad entry. /// </summary> /// <param name="name">The wad entry name.</param> /// <param name="resourceNamespace">The resource namespace of this /// entry.</param> /// <param name="data">The data for this entry.</param> public WadEntry(UpperString name, ResourceNamespace resourceNamespace, byte[] data) { Path = new EntryPath(name); Name = Path.Name; Namespace = resourceNamespace; Data = data; }
public void BatchDeleteTest() { List <string> tmps = RSHelper.RSPut(Bucket, 2); RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值 int i = 0; foreach (string k in tmps) { keys [i++] = new EntryPath(Bucket, k); } CallRet actual; actual = target.BatchDelete(keys); if (actual.OK) { foreach (string k in tmps) { RSHelper.RSDel(Bucket, k); } } Assert.IsTrue(actual.OK, "BatchStatTest Failure");; }
private static bool UploadRemoteFile(string url, EntryPath path) { RSClient client = new RSClient(); CallRet result = client.Fetch(url, path); return(result.OK); }
public async Task <bool> PreFetchAsync(EntryPath path) { string url = Config.PREFETCH_HOST + "/prefetch/" + path.Base64EncodedURI; CallRet ret = await CallAsync(url); return(ret.OK); }
public static void WaterMarkPop(FileTypeDirEnum dir, string key) { Qiniu.Conf.Config.ACCESS_KEY = QiniuConfig.AccessKey; Qiniu.Conf.Config.SECRET_KEY = QiniuConfig.SecretKey; //设置空间 string bucket = QiniuUtil.GetServerBucket(dir); //实例化一个entry对象 EntryPath entry = new EntryPath(bucket, key); string ext = QiniuUtil.GetKeyWithExt(key); string fops = string.Format("avthumb/{0}/{1}", ext, QiniuConfig.GetWaterText()); //设置切片的队列 string pipeline = "yihui_queue"; //可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。 String urlbase64 = Qiniu.Util.Base64URLSafe.Encode(String.Format("{0}:{1}", bucket, key)); String pfops = fops + "|saveas/" + urlbase64; //实例化一个fop对象主要进行后续转码操作 Qiniu.RS.Pfop fop = new Qiniu.RS.Pfop(); Uri uri = new Uri(QiniuConfig.UploadCallback); try { string s = fop.Do(entry, new[] { pfops }, uri, pipeline, 1); } catch (Exception ex) { Trace.WriteLine(ex); } }
public static bool VideoCutPiece(FileTypeDirEnum dir, string key) { Qiniu.Conf.Config.ACCESS_KEY = QiniuConfig.AccessKey; Qiniu.Conf.Config.SECRET_KEY = QiniuConfig.SecretKey; //设置空间 string bucket = QiniuUtil.GetServerBucket(dir); //实例化一个entry对象 EntryPath entry = new EntryPath(bucket, key); //设置切片操作参数 String fops = "avthumb/m3u8/segtime/15/vb/240k"; //设置切片的队列 string pipeline = "yihui_queue"; //可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。 String urlbase64 = Qiniu.Util.Base64URLSafe.Encode(String.Format("{0}:cut_{1}", bucket, key)); String pfops = fops + "|saveas/" + urlbase64; //实例化一个fop对象主要进行后续转码操作 Qiniu.RS.Pfop fop = new Qiniu.RS.Pfop(); Uri uri = new Uri(QiniuConfig.UploadCallback); try { string s = fop.Do(entry, new[] { pfops }, uri, pipeline); } catch (Exception ex) { Trace.WriteLine(ex); } return(false); }
public static async Task RSDel(string bucket, string key) { RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath scope = new EntryPath(bucket, key); // TODO: 初始化为适当的值 CallRet actual; actual = await target.DeleteAsync(scope); }
public static void RSDel(string bucket, string key) { RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath scope = new EntryPath(bucket, key); // TODO: 初始化为适当的值 CallRet actual; actual = target.Delete(scope); }
public FileEntry GetFileInFolder(EntryPath Path) { foreach (var File in FileEntryTable.Select("directory=? AND name=?", Path.Directory, Path.BaseName)) { return(File); } throw (new Exception("Can't find file '" + Path.Directory + '/' + Path.BaseName + "'")); }
public void AddFile(EntryPath Path) { AddFile(new FileEntry() { directory = Path.Directory, name = Path.BaseName, type = FileEntryType.File, reference = 0, }); }
public string GetCurrentDirectoryName() { if (!EntryPath.Contains('/')) { return(EntryPath); } var pathParts = EntryPath.Split('/'); return(pathParts[pathParts.Length - 1]); }
private static PK3Entry ReadZipEntry(ZipArchiveEntry zipEntry) { string pathText = ProcessZipPath(zipEntry); EntryPath path = new EntryPath(pathText); ResourceNamespace resourceNamespace = ResourceNamespaceHelper.From(path); byte[] data = DecompressZipEntry(zipEntry); return(new PK3Entry(path, resourceNamespace, data)); }
public void StatTest() { RSClient target = new RSClient(); //YES EntryPath scope = new EntryPath(Bucket, tmpKeys[0]); Entry actual; actual = target.Stat(scope); Assert.IsTrue(actual.OK, "StatTest Failure"); }
public static string UploadFile(string url, string channel = "") { var guid = Guid.NewGuid().ToString().RemoveDash(); EntryPath path = new EntryPath(Buket, channel + "/" + guid); if (UploadRemoteFile(url, path)) { return(channel + "/" + guid); } return(string.Empty); }
public void BatchStatTest() { RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值 keys[0] = new EntryPath(Bucket, tmpKeys[0]); keys[1] = new EntryPath(Bucket, tmpKeys[1]); //error params List <BatchRetItem> actual; actual = target.BatchStat(keys); Assert.IsTrue(actual.Count == 2, "BatchStatTest Failure"); }
protected override ICopyCallback GetCopyCallback(string destination) { var xaml = EntryPath; if (string.IsNullOrWhiteSpace(xaml)) { return(new CopyCallback(null)); } var resources = EntryPath.ApartFromLast(".xaml", StringComparison.OrdinalIgnoreCase); return(new CopyCallback(info => { var filename = info.Key; return FileUtils.ArePathsEqual(filename, xaml) ? Path.Combine(destination, Path.GetFileName(xaml)) : FileUtils.IsAffectedBy(filename, resources) ? Path.Combine(destination, FileUtils.GetRelativePath(filename, resources)) : null; })); }
public async Task StatTest() #endif { RSClient target = new RSClient(); //YES EntryPath scope = new EntryPath(Bucket, tmpKeys[0]); Entry actual; #if NET20 || NET40 actual = target.Stat(scope); Assert.IsTrue(actual.OK, "StatTest Failure"); #else actual = await target.StatAsync(scope); Assert.True(actual.OK, "StatTest Failure"); #endif }
protected override ICopyCallback GetCopyCallback(string destination) { var bitmapExtension = Path.GetExtension(EntryPath); var mainEntry = EntryPath.ApartFromLast(bitmapExtension) + FontObject.FontExtension; return(new CopyCallback(info => { if (FileUtils.ArePathsEqual(info.Key, mainEntry)) { return destination; } if (FileUtils.ArePathsEqual(info.Key, EntryPath)) { return destination.ApartFromLast(FontObject.FontExtension) + bitmapExtension; } return null; })); }
public async Task BatchStatTest() #endif { RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值 keys[0] = new EntryPath(Bucket, tmpKeys[0]); keys[1] = new EntryPath(Bucket, tmpKeys[1]); //error params List <BatchRetItem> actual; #if NET20 || NET40 actual = target.BatchStat(keys); Assert.IsTrue(actual.Count == 2, "BatchStatTest Failure"); #else actual = await target.BatchStatAsync(keys); Assert.True(actual.Count == 2, "BatchStatTest Failure"); #endif }
/// <summary> /// 处理视频缩略图 /// </summary> /// <param name="dir"></param> /// <param name="key"></param> /// <param name="fileImg"></param> /// <returns></returns> public static bool GetVideoThumbnailImg(FileTypeDirEnum dir, string key, out string fileImg) { Qiniu.Conf.Config.ACCESS_KEY = QiniuConfig.AccessKey; Qiniu.Conf.Config.SECRET_KEY = QiniuConfig.SecretKey; //设置空间 string bucket = QiniuUtil.GetServerBucket(dir); //实例化一个entry对象 EntryPath entry = new EntryPath(bucket, key); string name = String.Format("thumbnail-{0}.jpg", QiniuUtil.GetKeyWithoutExt(key)); fileImg = QiniuUtil.GetFullUrl(name, dir); //设置操作参数 String fops = "vframe/jpg/offset/5"; //设置队列 string pipeline = "yihui_queue"; //可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。 String urlbase64 = Qiniu.Util.Base64URLSafe.Encode(String.Format("{0}:{1}", bucket, name)); String pfops = fops + "|saveas/" + urlbase64; //实例化一个fop对象主要进行后续转码操作 Qiniu.RS.Pfop fop = new Qiniu.RS.Pfop(); Uri uri = new Uri(QiniuConfig.UploadCallback); try { string s = fop.Do(entry, new[] { pfops }, uri, pipeline); return(true); } catch (Exception ex) { Trace.WriteLine(ex); } return(false); }
public async Task BatchDeleteTest() #endif { #if NET20 || NET40 List <string> tmps = RSHelper.RSPut(Bucket, 2); #else List <string> tmps = await RSHelper.RSPut(Bucket, 2); #endif RSClient target = new RSClient(); // TODO: 初始化为适当的值 EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值 int i = 0; foreach (string k in tmps) { keys [i++] = new EntryPath(Bucket, k); } CallRet actual; #if NET20 || NET40 actual = target.BatchDelete(keys); if (actual.OK) { foreach (string k in tmps) { RSHelper.RSDel(Bucket, k); } } Assert.IsTrue(actual.OK, "BatchStatTest Failure"); #else actual = await target.BatchDeleteAsync(keys); if (actual.OK) { foreach (string k in tmps) { await RSHelper.RSDel(Bucket, k); } } Assert.True(actual.OK, "BatchStatTest Failure"); #endif }
/// <summary> /// Takes an entry path and gets the namespace from it. /// </summary> /// <param name="path">The entry path.</param> /// <returns>The namespace for the path.</returns> public static ResourceNamespace From(EntryPath path) { if (path.Folders.Empty()) { return(ResourceNamespace.Global); } switch (path.Folders.First().ToUpper()) { case "ACS": return(ResourceNamespace.ACS); case "FLATS": return(ResourceNamespace.Flats); case "FONTS": return(ResourceNamespace.Fonts); case "GRAPHICS": return(ResourceNamespace.Graphics); case "MUSIC": return(ResourceNamespace.Music); case "SOUNDS": return(ResourceNamespace.Sounds); case "SPRITES": return(ResourceNamespace.Sprites); case "TEXTURES": return(ResourceNamespace.Textures); default: return(ResourceNamespace.Global); } }
public void CreateFolder(EntryPath Path, uint mode) { Console.WriteLine("CreateFolder: '{0}'", Path.FullPath); _CreateFolder(Path.Directory, Path.BaseName, mode); _CreateFolder(Path.FullPath, null, mode); }
private void _entryPathPair(string bucketSrc, string keySrc, string bucketDest, string keyDest) { this.src = new EntryPath(bucketSrc, keySrc); this.dest = new EntryPath(bucketDest, keyDest); }
/// <summary> /// Initializes a new instance of the <see cref="Qiniu.RS.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); }
/// <summary> /// Initializes a new instance of the <see cref="Qiniu.RS.EntryPathPair"/> class. /// </summary> public EntryPathPair (EntryPath src, EntryPath des) { this.src = src; this.dest = des; }
public FileEntry GetFileInFolder(EntryPath Path) { foreach (var File in FileEntryTable.Select("directory=? AND name=?", Path.Directory, Path.BaseName)) { return File; } throw (new Exception("Can't find file '" + Path.Directory + '/' + Path.BaseName + "'")); }
public IEnumerable<FileEntry> GetFilesInFolder(EntryPath Path) { foreach (var File in FileEntryTable.Select("directory=?", Path.FullPath)) { yield return File; } }