Beispiel #1
0
 public StatRet(CallRet ret)
     : base(ret)
 {
     if (OK && Response != null)
     {
         try
         {
             Unmarshal(Response);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
             this.Exception = e;
         }
     }
 }
Beispiel #2
0
 public PutAuthRet(CallRet ret)
     : base(ret)
 {
     if (!String.IsNullOrEmpty(Response))
     {
         try
         {
             Unmarshal(Response);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
             this.Exception = e;
         }
     }
 }
Beispiel #3
0
        /// <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));
        }
Beispiel #4
0
        /// <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));
        }
Beispiel #5
0
        public static async Task <ExifRet> CallAsync(string url)
        {
            CallRet callRet = await FileOpClient.GetAsync(url);

            return(new ExifRet(callRet));
        }
Beispiel #6
0
        public static ExifRet Call(string url)
        {
            CallRet callRet = FileOpClient.Get(url);

            return(new ExifRet(callRet));
        }
Beispiel #7
0
        public async static Task <ImageInfoRet> Call(string url)
        {
            CallRet callRet = await FileOpClient.Get(url);

            return(new ImageInfoRet(callRet));
        }
        public static ImageInfoRet Call(string url)
        {
            CallRet callRet = FileOpClient.Get(url);

            return(new ImageInfoRet(callRet));
        }
Beispiel #9
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="bucket">七牛云存储空间名称</param>
        /// <param name="key">需要删除的文件key</param>
        /// <returns></returns>
        public CallRet Delete(EntryPath scope)
        {
            CallRet callRet = op(FileHandle.DELETE, scope);

            return(new Entry(callRet));
        }
Beispiel #10
0
        /// <summary>
        /// 文件信息查看
        /// </summary>
        /// <param name="scope"></param>
        /// <returns>文件的基本信息,见<see cref="Entry">Entry</see></returns>
        public Entry Stat(EntryPath scope)
        {
            CallRet callRet = op(FileHandle.STAT, scope);

            return(new Entry(callRet));
        }
Beispiel #11
0
        public PutAuthRet PutAuth()
        {
            CallRet callRet = Conn.Call(Config.IO_HOST + "/put-auth/");

            return(new PutAuthRet(callRet));
        }
Beispiel #12
0
 public static void PrintRet(CallRet callRet)
 {
     Console.WriteLine("\n[CallRet]");
     Console.WriteLine("StatusCode: " + callRet.StatusCode.ToString());
     Console.WriteLine("Response:\n" + callRet.Response);
     Console.WriteLine();
 }
Beispiel #13
0
        public static void ImageOps()
        {
            Console.WriteLine("\n===> FileOp.ImageInfo");
            ImageInfoRet infoRet = ImageOp.ImageInfo("http://" + DEMO_DOMAIN + "/" + key);

            PrintRet(infoRet);
            if (infoRet.OK)
            {
                Console.WriteLine("Format: " + infoRet.Format);
                Console.WriteLine("Width: " + infoRet.Width);
                Console.WriteLine("Heigth: " + infoRet.Height);
                Console.WriteLine("ColorModel: " + infoRet.ColorModel);
            }
            else
            {
                Console.WriteLine("Failed to ImageInfo");
            }

            Console.WriteLine("\n===> FileOp.ImageExif");
            CallRet exifRet = ImageOp.ImageExif("http://" + DEMO_DOMAIN + "/" + key);

            PrintRet(exifRet);
            if (!exifRet.OK)
            {
                Console.WriteLine("Failed to ImageExif");
            }

            Console.WriteLine("\n===> FileOp.ImageViewUrl");
            ImageViewSpec viewSpec = new ImageViewSpec {
                Mode = 0, Width = 200, Height = 200
            };
            string viewUrl = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);

            Console.WriteLine("ImageViewUrl 1:" + viewUrl);
            viewSpec.Quality = 1;
            viewSpec.Format  = "gif";
            viewUrl          = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
            Console.WriteLine("ImageViewUrl 2:" + viewUrl);
            viewSpec.Quality = 90;
            viewSpec.Sharpen = 10;
            viewSpec.Format  = "png";
            viewUrl          = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
            Console.WriteLine("ImageViewUrl 3:" + viewUrl);

            Console.WriteLine("\n===> FileOp.ImageMogrifyUrl");
            ImageMogrifySpec mogrSpec = new ImageMogrifySpec {
                Thumbnail = "!50x50r", Gravity = "center", Rotate = 90,
                Crop      = "!50x50", Quality = 80, AutoOrient = true
            };
            string mogrUrl = ImageOp.ImageMogrifyUrl("http://" + DEMO_DOMAIN + "/" + key, mogrSpec);

            Console.WriteLine("ImageMogrifyUrl:" + mogrUrl);

            Console.WriteLine("\n===> Get");
            GetRet getRet = rs.Get(key, "save-as");

            PrintRet(getRet);
            if (getRet.OK)
            {
                Console.WriteLine("Hash: " + getRet.Hash);
                Console.WriteLine("FileSize: " + getRet.FileSize);
                Console.WriteLine("MimeType: " + getRet.MimeType);
                Console.WriteLine("Url: " + getRet.Url);
            }
            else
            {
                Console.WriteLine("Failed to Get");
            }
            Console.WriteLine("\n===> FileOp.ImageMogrifySaveAs");
            PutFileRet saveAsRet = rs.ImageMogrifySaveAs(getRet.Url, mogrSpec, key + ".mogr-save-as");

            PrintRet(saveAsRet);
            if (saveAsRet.OK)
            {
                Console.WriteLine("Hash: " + saveAsRet.Hash);
            }
            else
            {
                Console.WriteLine("Failed to ImageMogrifySaveAs");
            }
            Console.WriteLine("\n===> Get");
            getRet = rs.Get(key + ".mogr-save-as", "mogr-save-as.jpg");
            PrintRet(getRet);
            if (getRet.OK)
            {
                Console.WriteLine("Hash: " + getRet.Hash);
                Console.WriteLine("FileSize: " + getRet.FileSize);
                Console.WriteLine("MimeType: " + getRet.MimeType);
                Console.WriteLine("Url: " + getRet.Url);
            }
            else
            {
                Console.WriteLine("Failed to Get");
            }
        }