예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
파일: fops.cs 프로젝트: seamys/csharp-sdk
        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();
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        public JObject Upload([FromBody]JObject value)
        {
            if (!IsQiniuCallback(Request.Headers.Authorization))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            else
            {
                //HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
                //HttpRequestBase request = context.Request;//定义传统request对象
                //string name = request.Form["name"];

                /*
                {{
                  "name": "贝瓦儿歌—小兔子乖乖.mp4",
                  "key": "o_1a0ju5mn81s02d4dp4uvip1evc9.mp4",
                  "hash": "lsW45LizUGPP9O3GZtbJLSymlrlE",
                  "filesize": "17839736",
                  "processId": ""
                }}
                */

                /*
                默认用hash值作为文件名存储,除非在前端指定了unique_names=ture,会生成维一的文件名称,如果不指定unique-names=true,用hash值作为文件名存储时相同文件内容的文件不会重复存储。

                //通过get请求查询avinfo, 如果在UpToken中已经指定了返回avinfo,就不需要重新通过Get请求获取。但返回数据格式稍有不同.
                用以使用http://{domain}/{file hash}?avinfo 或空间中的file name查询音视频文件信息 http://{domain}/{file name}?avinfo
                refer to http://developer.qiniu.com/docs/v6/api/reference/fop/av/avinfo.html
                for example: http://7xlw23.com1.z0.glb.clouddn.com/o_1a0js9ea71uqvlsh12rli6b1rsn9.mp4?avinfo

                HttpClient client = new HttpClient();
                HttpResponseMessage responseResult = client.GetAsync("http://" + "7xlw23.com1.z0.glb.clouddn.com" +"/"+ value.GetValue("hash").ToString() + "?avinfo").Result;
                JObject result = responseResult.Content.ReadAsAsync<JObject>().Result;

                /*
                通过Get请求avinfor返回的信息:
                {{
                  "streams": [
                    {
                      "index": 0,
                      "codec_name": "h264",
                      "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
                      "profile": "Constrained Baseline",
                      "codec_type": "video",
                      "codec_time_base": "1/50",
                      "codec_tag_string": "avc1",
                      "codec_tag": "0x31637661",
                      "width": 720,
                      "height": 480,
                      "has_b_frames": 0,
                      "sample_aspect_ratio": "1:1",
                      "display_aspect_ratio": "3:2",
                      "pix_fmt": "yuv420p",
                      "level": 30,
                      "chroma_location": "left",
                      "is_avc": "1",
                      "nal_length_size": "4",
                      "r_frame_rate": "25/1",
                      "avg_frame_rate": "25/1",
                      "time_base": "1/25",
                      "start_pts": 0,
                      "start_time": "0.000000",
                      "duration_ts": 3406,
                      "duration": "136.240000",
                      "bit_rate": "920580",
                      "bits_per_raw_sample": "8",
                      "nb_frames": "3406",
                      "disposition": {
                        "default": 1,
                        "dub": 0,
                        "original": 0,
                        "comment": 0,
                        "lyrics": 0,
                        "karaoke": 0,
                        "forced": 0,
                        "hearing_impaired": 0,
                        "visual_impaired": 0,
                        "clean_effects": 0,
                        "attached_pic": 0
                      },
                      "tags": {
                        "creation_time": "1970-01-01 00:00:00",
                        "language": "und",
                        "handler_name": "\fVideoHandler"
                      }
                    },
                    {
                      "index": 1,
                      "codec_name": "aac",
                      "codec_long_name": "AAC (Advanced Audio Coding)",
                      "profile": "LC",
                      "codec_type": "audio",
                      "codec_time_base": "1/44100",
                      "codec_tag_string": "mp4a",
                      "codec_tag": "0x6134706d",
                      "sample_fmt": "fltp",
                      "sample_rate": "44100",
                      "channels": 2,
                      "channel_layout": "stereo",
                      "bits_per_sample": 0,
                      "r_frame_rate": "0/0",
                      "avg_frame_rate": "0/0",
                      "time_base": "1/44100",
                      "start_pts": 0,
                      "start_time": "0.000000",
                      "duration_ts": 5958656,
                      "duration": "135.116916",
                      "bit_rate": "123584",
                      "nb_frames": "5819",
                      "disposition": {
                        "default": 1,
                        "dub": 0,
                        "original": 0,
                        "comment": 0,
                        "lyrics": 0,
                        "karaoke": 0,
                        "forced": 0,
                        "hearing_impaired": 0,
                        "visual_impaired": 0,
                        "clean_effects": 0,
                        "attached_pic": 0
                      },
                      "tags": {
                        "creation_time": "1970-01-01 00:00:00",
                        "language": "und",
                        "handler_name": "\fSoundHandler"
                      }
                    }
                  ],
                  "format": {
                    "nb_streams": 2,
                    "nb_programs": 0,
                    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
                    "format_long_name": "QuickTime / MOV",
                    "start_time": "0.000000",
                    "duration": "136.240000",
                    "size": "17839736",
                    "bit_rate": "1047547",
                    "probe_score": 100,
                    "tags": {
                      "major_brand": "isom",
                      "minor_version": "512",
                      "compatible_brands": "mp41",
                      "creation_time": "1970-01-01 00:00:00"
                    }
                  }
                }}

                跟随UpToken一起返回的信息:
                {{
                  "name": "贝瓦儿歌—小兔子乖乖.mp4",
                  "key": "o_1a0ju5mn81s02d4dp4uvip1evc9.mp4",
                  "hash": "lsW45LizUGPP9O3GZtbJLSymlrlE",
                  "filesize": "17839736",
                  "avinfo": "{\"audio\":{\"Disposition\":{\"attached_pic\":0},\"avg_frame_rate\":\"0/0\",\"bit_rate\":\"123584\",\"channels\":2,\"codec_name\":\"aac\",\"codec_type\":\"audio\",\"duration\":\"135.116916\",\"index\":1,\"nb_frames\":\"5819\",\"r_frame_rate\":\"0/0\",\"sample_fmt\":\"fltp\",\"sample_rate\":\"44100\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"}},\"format\":{\"bit_rate\":\"1047547\",\"duration\":\"136.240000\",\"format_long_name\":\"QuickTime / MOV\",\"format_name\":\"mov,mp4,m4a,3gp,3g2,mj2\",\"nb_streams\":2,\"size\":\"17839736\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"}},\"video\":{\"Disposition\":{\"attached_pic\":0},\"avg_frame_rate\":\"25/1\",\"bit_rate\":\"920580\",\"codec_name\":\"h264\",\"codec_type\":\"video\",\"display_aspect_ratio\":\"3:2\",\"duration\":\"136.240000\",\"height\":480,\"index\":0,\"nb_frames\":\"3406\",\"pix_fmt\":\"yuv420p\",\"r_frame_rate\":\"25/1\",\"sample_aspect_ratio\":\"1:1\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"},\"width\":720}}"
                }}
                */
                string videoWidth = ((JObject)((JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(((Newtonsoft.Json.Linq.JValue)(value.GetValue("avinfo"))).Value.ToString())).GetValue("video")).GetValue("width").ToString();
                string videoHeight = ((JObject)((JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(((Newtonsoft.Json.Linq.JValue)(value.GetValue("avinfo"))).Value.ToString())).GetValue("video")).GetValue("height").ToString();

                //获取文件信息成功,开始发送pfop请求进行数据处理
                // refer to: http://developer.qiniu.com/docs/v6/api/reference/fop/pfop/pfop.html

                string bucket = "ylhyh";
                string domain = "7xlw23.com1.z0.glb.clouddn.com";
                string fileKey = value.GetValue("key").ToString();

                //缩略图: http://7xlw23.com1.z0.glb.clouddn.com/o_1a0kjb5u9td94gb1ooortjtei9.mp4?vframe/png/offset/100/w/400/h/300

                /*
                //bucket=<urlEncodedBucket>&key=<urlEncodedKey>&fops=<urlEncodedFops>&notifyURL=<urlEncodedPersistentNotifyUrl>&force=<Force>&pipeline=<Pipeline Name>
                string strContent = "bucket=" + HttpUtility.UrlEncode(bucket)
                    + "&key=" + HttpUtility.UrlEncode(fileKey)
                    + "&fops=" + HttpUtility.UrlEncode(fops)
                    + "&notifyURL=" + HttpUtility.UrlEncode("http://ylhyh.onmypc.net:90/QiniuDemo/api/QiniuCallback/Fop");

                //http://developer.qiniu.com/docs/v6/api/reference/security/access-token.html#access-token-algorithm
                string signingStr = "/pfop/\n" + strContent;

                HttpClient client = new HttpClient();
                HttpContent content = new StringContent(strContent, System.Text.Encoding.UTF8);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("QBox", "");
                HttpResponseMessage responseResult = client.PostAsync("http://api.qiniu.com/pfop/", content).Result;
                JObject result = responseResult.Content.ReadAsAsync<JObject>().Result;
                */
                /*
                //Use the first frame as thumbnail.
                string thumbnail = "vframe/jpg/offset/7";

                string thumbKey = "wobo_" + Guid.NewGuid().ToString("N") + ".jpg";
                //string thumbencodedEntryURI = Qiniu.Util.Base64URLSafe.Encode(bucket + ":" + thumbKey);
                //string thumbsaveas = "|saveas/" + thumbencodedEntryURI;

                string baseUrl = GetPolicy.MakeBaseUrl(domain, fileKey);
                string private_url = GetPolicy.MakeRequest(baseUrl + "?" + thumbnail);// +thumbsaveas);

                HttpClient client = new HttpClient();
                Stream vframeResponse = client.GetStreamAsync(private_url).Result;
                string thumbFilepath = Path.GetTempFileName();
                FileStream fileStream = File.OpenWrite(thumbFilepath);
                byte[] buffer = new byte[4096];
                int count = vframeResponse.Read(buffer, 0, buffer.Length);

                while (count > 0)
                {
                    fileStream.Write(buffer, 0, count);
                    count = vframeResponse.Read(buffer, 0, buffer.Length);
                }

                vframeResponse.Close();
                fileStream.Close();

                var policy = new PutPolicy(bucket, 3600);
                string upToken = policy.Token();
                PutExtra extra = new PutExtra();
                IOClient ioClient = new IOClient();
                ioClient.PutFile(upToken, thumbKey, thumbFilepath, extra);
                File.Delete(thumbFilepath);
                */

                // 音视频切片: http://developer.qiniu.com/docs/v6/api/reference/fop/av/segtime.html
                string fops = "avthumb/m3u8/segtime/15/video_240k";

                string m3u8Key = "wobo_" + Guid.NewGuid().ToString("N") + ".m3u";
                string m3uencodedEntryURI = Qiniu.Util.Base64URLSafe.Encode(bucket + ":" + m3u8Key);
                string m3usaveas = "|saveas/" + m3uencodedEntryURI;

                fops += m3usaveas;
                //fops += ";" + thumbnail + thumbsaveas;

                Qiniu.RS.Pfop pfop = new Qiniu.RS.Pfop();
                string result = pfop.Do(new Qiniu.RS.EntryPath(bucket, fileKey), fops.Split(';'), new Uri("http://ylhyh.onmypc.net:90/QiniuDemo/api/QiniuCallback/Fop"), "");

                return value;
            }
        }
예제 #6
0
        public HttpResponseMessage Callback([FromBody]JObject postData)
        {
            #if DEBUG
            Debug.WriteLine("Callback");
            #endif

            #region 数据返回格式
            /*
            {
              "name": "贝瓦儿歌—小兔子乖乖.mp4",
              "key": "o_1a11dud60vq11dmo1guh1gk8glt9.mp4",
              "hash": "lsW45LizUGPP9O3GZtbJLSymlrlE",
              "filesize": "17839736",
              "avinfo": "{\"audio\":{\"Disposition\":{\"attached_pic\":0},\"avg_frame_rate\":\"0/0\",\"bit_rate\":\"123584\",\"channels\":2,\"codec_name\":\"aac\",\"codec_type\":\"audio\",\"duration\":\"135.116916\",\"index\":1,\"nb_frames\":\"5819\",\"r_frame_rate\":\"0/0\",\"sample_fmt\":\"fltp\",\"sample_rate\":\"44100\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"}},\"format\":{\"bit_rate\":\"1047547\",\"duration\":\"136.240000\",\"format_long_name\":\"QuickTime / MOV\",\"format_name\":\"mov,mp4,m4a,3gp,3g2,mj2\",\"nb_streams\":2,\"size\":\"17839736\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"}},\"video\":{\"Disposition\":{\"attached_pic\":0},\"avg_frame_rate\":\"25/1\",\"bit_rate\":\"920580\",\"codec_name\":\"h264\",\"codec_type\":\"video\",\"display_aspect_ratio\":\"3:2\",\"duration\":\"136.240000\",\"height\":480,\"index\":0,\"nb_frames\":\"3406\",\"pix_fmt\":\"yuv420p\",\"r_frame_rate\":\"25/1\",\"sample_aspect_ratio\":\"1:1\",\"start_time\":\"0.000000\",\"tags\":{\"creation_time\":\"1970-01-01 00:00:00\"},\"width\":720}}"
            }
            */
            #endregion

            if (!IsQiniuCallback(Request.Headers.Authorization))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            else
            {
                //得到视频尺寸及其它信息
                string fileKey = postData.GetValue("key").ToString();
                string videoWidth = ((JObject)((JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(((Newtonsoft.Json.Linq.JValue)(postData.GetValue("avinfo"))).Value.ToString())).GetValue("video")).GetValue("width").ToString();
                string videoHeight = ((JObject)((JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(((Newtonsoft.Json.Linq.JValue)(postData.GetValue("avinfo"))).Value.ToString())).GetValue("video")).GetValue("height").ToString();

                //生成缩略图
                // refer to http://developer.qiniu.com/docs/v6/api/reference/fop/av/vframe.html
                // refer to http://developer.qiniu.com/docs/v6/api/reference/fop/saveas.html
                string thumbnail = "vframe/jpg/offset/7";

                string thumbKey = "thumbnail_" + Guid.NewGuid().ToString("N") + ".jpg";
                string thumbencodedEntryURI = Qiniu.Util.Base64URLSafe.Encode(bucket + ":" + thumbKey);
                string thumbsaveas = "|saveas/" + thumbencodedEntryURI;

                string fops = thumbnail + thumbsaveas;
                Pfop pfop = new Pfop();
                string persistentId_thumb = pfop.Do(new EntryPath(bucket, fileKey), new string[] { fops }, new Uri("http://wobo.ylhyh.onmypc.net:810/QiniuSample/api/Video/Notify"), GetPipeline());
            #if DEBUG
                Debug.WriteLine(persistentId_thumb);
            #endif

                //音视频切片: http://developer.qiniu.com/docs/v6/api/reference/fop/av/segtime.html
                fops = "avthumb/m3u8/segtime/15/video_240k";

                string m3u8Key = "m3u8_" + Guid.NewGuid().ToString("N") + ".m3u";
                string m3uencodedEntryURI = Qiniu.Util.Base64URLSafe.Encode(bucket + ":" + m3u8Key);
                string m3usaveas = "|saveas/" + m3uencodedEntryURI;

                fops += m3usaveas;
                pfop = new Pfop();
                string persistentId_m3u8 = pfop.Do(new EntryPath(bucket, fileKey), new string[] { fops }, new Uri("http://wobo.ylhyh.onmypc.net:810/QiniuSample/api/Video/Notify"), GetPipeline());

            #if DEBUG
                Debug.WriteLine(persistentId_m3u8);
            #endif
                //ToDo 创建视频记录, 并把生成缩略图片切片的File Key和Persistent Id存储起来,根据Persistent Id可以查询每个处理的状态
                //thumbKey, persistentId_thumb, m3u8Key, persistentId_m3u8
                int videoId = 3;

                string returnJson = "{\"videoId\":\"" + videoId + "\"}";

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StringContent(returnJson, Encoding.UTF8, "application/json");

                return response;
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            const string domain = "http://obftsogus.bkt.clouddn.com/";
            //设置上传的空间
            String bucket = "test2";

            Console.WriteLine("初始化");
            Config.Init();

            #region

            Console.WriteLine("上传测试,按键继续……");
            //Console.ReadLine();

            IOClient target = new IOClient();
            PutExtra extra  = new PutExtra();

            //设置上传的文件的key值
            String key = string.Format("{0}.JPG", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));

            //普通上传,只需要设置上传的空间名就可以了,第二个参数可以设定token过期时间
            PutPolicy put = new PutPolicy(bucket, 3600);

            //调用Token()方法生成上传的Token
            string upToken = put.Token();
            Console.WriteLine("upToken:" + upToken);

            //上传文件的路径
            String filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "测试图片.JPG");
            var    bytes    = File.ReadAllBytes(filePath);

            var url = string.Empty;
            using (var stream = new MemoryStream(bytes))
            {
                //调用PutFile()方法上传
                PutRet ret = target.PutAsync(upToken, key, stream, extra).Result;

                //打印出相应的信息
                Console.WriteLine(ret.Response);

                if (ret.OK)
                {
                    url = string.Concat(domain, ret.key);
                    Console.WriteLine("上传成功");
                }
                else
                {
                    Console.WriteLine("上传失败");
                }

                Console.WriteLine(ret.key);
            }

            //Console.ReadLine();

            #endregion

            #region 获取文件信息

            Console.WriteLine("获取基本信息测试,按键继续……");
            //Console.ReadLine();

            //实例化一个RSClient对象,用于操作BucketManager里面的方法
            RSClient client = new RSClient();
            //调用Stat方法获取文件的信息
            Entry entry = client.StatAsync(new EntryPath(bucket, key)).Result;
            if (entry.OK)
            {
                Console.WriteLine("获取基本信息成功");

                //打印文件的hash、fsize等信息
                Console.WriteLine("Hash: " + entry.Hash);
                Console.WriteLine("Fsize: " + entry.Fsize);
                Console.WriteLine("PutTime: " + entry.PutTime);
                Console.WriteLine("MimeType: " + entry.MimeType);
                //Console.ReadLine();
            }
            else
            {
                Console.WriteLine("获取基本信息失败");
            }

            #endregion

            #region  载文件

            Console.WriteLine("下载文件测试,按键继续……");
            //Console.ReadLine();

            using (var httpClient = new HttpClient())
            {
                using (var response = httpClient.GetAsync(url))
                {
                    if (response.Result.IsSuccessStatusCode)
                    {
                        var s = response.Result.Content.ReadAsByteArrayAsync().Result;

                        var downLoadPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                        string.Concat(Guid.NewGuid().ToString("N"), ".jpg"));
                        File.WriteAllBytes(downLoadPath, s);

                        if (File.Exists(downLoadPath))
                        {
                            Console.WriteLine("下载成功,路径:" + downLoadPath);
                            Console.WriteLine("按任意键继续……");
                            //Console.ReadLine();

                            File.Delete(downLoadPath);
                        }
                        else
                        {
                            Console.WriteLine("下载失败");
                        }
                    }
                }
            }

            #endregion

            #region  除单个文件

            Console.WriteLine("删除文件测试,按任意键继续……");
            //Console.ReadLine();

            //实例化一个RSClient对象,用于操作BucketManager里面的方法
            client = new RSClient();
            var ret2 = client.DeleteAsync(new EntryPath(bucket, key)).Result;
            if (ret2.OK)
            {
                Console.WriteLine("删除文件" + url + "成功");
            }
            else
            {
                Console.WriteLine("删除文件失败");
            }

            //Console.ReadLine();

            #endregion

            #region   视频并获取首帧(上传的视频在一天后删除)

            Console.WriteLine("上传视频并获取首帧(上传的视频在一天后删除),按任意键继续……");
            //Console.ReadLine();

            put = new PutPolicy(bucket, 3600);
            put.DeleteAfterDays = 1;

            key = string.Format("视频-{0}.mov", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
            //调用Token()方法生成上传的Token
            upToken = put.Token();
            Console.WriteLine("upToken:" + upToken);

            //上传文件的路径
            filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "ios视频.mov");
            bytes    = File.ReadAllBytes(filePath);

            url = string.Empty;
            using (var stream = new MemoryStream(bytes))
            {
                ResumablePutExtra putExtra = new ResumablePutExtra();
                putExtra.MimeType   = "application/octet-stream";
                putExtra.Notify    += new EventHandler <PutNotifyEvent>(extra_Notify);
                putExtra.NotifyErr += new EventHandler <PutNotifyErrorEvent>(extra_NotifyErr);
                var resumablePut = new ResumablePut(new Settings(), putExtra);

                //todo:视频文件较大,改为断点续传
                //调用PutFile()方法上传
                var ret3 = resumablePut.PutFileAsync(upToken, filePath, key).Result;

                //打印出相应的信息
                Console.WriteLine(ret3.Response);

                if (ret3.OK)
                {
                    //url = string.Concat(domain, ret3.key);
                    Console.WriteLine("上传成功");
                }
                else
                {
                    Console.WriteLine("上传失败");
                }

                // Console.WriteLine(ret3.key);
            }

            //Console.ReadLine();

            Console.WriteLine("触发持久化操作,获取首帧,按任意键继续……");
            //Console.ReadLine();

            //实例化一个entry对象
            var entryPath = new EntryPath(bucket, key);

            //设置转码操作参数
            String fops = "vframe/jpg/offset/1/w/480/h/360"; //"vframe/jpg/offset/1/w/480/h/360/rotate/90"; //"avthumb/mp4/s/640x360/vb/1.25m";
            //设置转码的队列
            String pipeline = "yourpipelinename";

            //可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。
            String urlbase64 = Qiniu.Util.Base64URLSafe.Encode(string.Format("{0}:视频首页.jpg", domain));
            String pfops     = fops;// + "|saveas/" + urlbase64;

            //实例化一个fop对象主要进行后续转码操作
            Qiniu.RS.Pfop fop = new Qiniu.RS.Pfop();

            Uri uri = new Uri("http://www.baidu.com");

            var s2 = fop.DoAsync(entryPath, new[] { pfops }, uri, null, 1).Result;
            Console.WriteLine(s2);
            //Console.ReadLine();

            #endregion
        }