Esempio n. 1
0
 public KeePassQiniu.KeePassQiniuExt.UploadError UploadLocal(string name, string dbfile, out string tips) {
     Init();
     System.Net.IWebProxy webProxy = null;
     if(KeePassQiniu.KeePassQiniuConfig.Default.UseProxy) {
         webProxy = new System.Net.WebProxy(KeePassQiniu.KeePassQiniuConfig.Default.ProxyUrl, true);
     }
     // bak first
     if(KeePassQiniu.KeePassQiniuConfig.Default.AutoBackup) {
         MyRSClient moveclient = new MyRSClient();
         CallRet moveret = moveclient.Move(new EntryPathPair(KeePassQiniu.KeePassQiniuConfig.Default.QiniuBucket, name, "backup_" + System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + "_" + name));
         if(!moveret.OK) {
             tips = moveret.Response;
             return KeePassQiniuExt.UploadError.AUTOBAK_ERROR;
         }
     }
     // upload
     var policy = new PutPolicy(KeePassQiniu.KeePassQiniuConfig.Default.QiniuBucket);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     client.Proxy = webProxy;
     PutRet uploadret = client.PutFile(upToken, name, dbfile, extra);
     if(!uploadret.OK) {
         tips = uploadret.Response;
         return KeePassQiniuExt.UploadError.UPLOAD_ERROR;
     }
     tips = string.Empty;
     return KeePassQiniuExt.UploadError.OK;
 }
Esempio n. 2
0
        public void PutFileWithoutKeyTest()
        {
            IOClient target = new IOClient();
            string key = NewKey;
            PrintLn (key);
            PutExtra extra = new PutExtra (); // TODO: 初始化为适当的值
            extra.MimeType = "text/plain";
            extra.Crc32 = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params = new System.Collections.Generic.Dictionary<string, string> ();
            PutPolicy put = new PutPolicy (Bucket);
            TmpFIle file = new TmpFIle (1024 * 10);
            target.PutFinished += new EventHandler<PutRet> ((o,e) => {
                file.Del ();
                if (e.OK) {
                    RSHelper.RSDel (Bucket, file.FileName);
                }
            });

            PutRet ret = target.PutFileWithoutKey (put.Token (),file.FileName, extra);

            //error params
            //target.PutFile("error", "error", "error", null);
            Assert.IsTrue (ret.OK, "PutFileTest Failure");
        }
Esempio n. 3
0
 /// <summary>
 /// 普通上传文件
 /// </summary>
 /// <param name="bucket"></param>
 /// <param name="key">utf-8 编码</param>
 /// <param name="fname"></param>
 public static void PutFile(string bucket, string key, string fname)
 {
     var policy = new PutPolicy(bucket, 3600);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     client.PutFile(upToken, key, fname, extra);
 }
Esempio n. 4
0
 public static bool PutFile(string key, string fname)
 {
     var policy = new PutPolicy(bucket, 3600);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     var putFile = client.PutFile(upToken, key, fname, extra);
     return putFile.OK;
 }
Esempio n. 5
0
 /// <summary>
 /// 上传文件 没有key
 /// </summary>
 /// <param name="bucket"></param>
 /// <param name="fname"></param>
 public static void PutFileWithoutKey(string bucket, string fname)
 {
     var policy = new PutPolicy(bucket, 3600);
     System.Console.WriteLine(policy);
     string upToken = policy.Token();
     IOClient target = new IOClient();
     PutExtra extra = new PutExtra();
     PutRet ret = target.PutFileWithoutKey(upToken, fname, extra);
     Console.WriteLine(ret.Response.ToString());
 }
Esempio n. 6
0
        public FileStat Upload(string filepath, bool isOverlay = false, string newname = "")
        {
            // 由外部检查获取成功与否
            filepath.Trim();

            if (false == File.Exists(filepath))
                throw new Exception("Error: Upload failed. File not Exists");

            if (newname == "")
                newname = getFilenameFromPath(filepath);

            PutPolicy put;
            IOClient target = new IOClient();
            PutExtra extra = new PutExtra();
            Entry entry = null;

            // 判断是否覆盖上传
            if(isOverlay && GetFileInfo(newname, out entry))
            {
                //覆盖上传,<bucket>:<key>,表示只允许用户上传指定key的文件。在这种格式下文件默认允许“修改”,已存在同名资源则会被本次覆盖。
                put = new PutPolicy(m_qiniuconf.bucketname + ":" + newname, 3600);
            }
            else if(!GetFileInfo(newname, out entry))
            {
                put = new PutPolicy(m_qiniuconf.bucketname, 3600);
            }
            else
            {
                return null;
            }

            // 调用Token()方法生成上传的Token
            string upToken = put.Token();

            // 调用PutFile()方法上传
            PutRet ret = target.PutFile(upToken, newname, filepath, extra);

            // 获取文件上传信息
            GetFileInfo(newname, out entry);

            FileStat file_stat;
            ConverEntryToFileStat(ref entry, out file_stat);

            file_stat.name = newname;

            return file_stat;
        }
Esempio n. 7
0
 /// <summary>
 ///     普通上传
 /// </summary>
 /// <param name="fname">文件本地路径</param>
 /// <param name="bucket">空间名称</param>
 /// <param name="key">文件key</param>
 /// <returns>key</returns>
 public string PutFile(string fname, string bucket = "", string key = "")
 {
     if (bucket == "")
     {
         bucket = BUCKET;
     }
     var policy = new PutPolicy(bucket, 3600);
     var upToken = policy.Token();
     var extra = new PutExtra();
     var client = new IOClient();
     var ret = client.PutFile(upToken, key, fname, extra);
     if (ret != null)
     {
         return ret.key;
     }
     return "";
 }
Esempio n. 8
0
        public static void PutTest()
        {
            IOClient target = new IOClient();
            string upToken = string.Empty;
            string key = LocalKey;
            //PrintLn(key);
            PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值
            extra.MimeType = "text/plain";
            extra.Crc32 = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params = new System.Collections.Generic.Dictionary<string, string>();
            extra.Scope = Bucket+":"+key;
            PutPolicy put = new PutPolicy(extra.Scope);

            PutRet ret = target.Put(put.Token(), key, "hello Qiniu Cloud!".ToStream(), extra);

            //Assert.IsTrue(ret.OK, "PutFileTest Failure");
        }
Esempio n. 9
0
		public static List<string> RSPut(string bucket,int num)
		{
			IOClient target = new IOClient(); 
			string key = "csharp" + Guid.NewGuid().ToString();
			//PrintLn(key);
			PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值
			extra.MimeType = "text/plain";
			PutPolicy put = new PutPolicy(bucket);
			List<string> newKeys=new List<string>();
			for (int i=0; i<num; i++) {
				key = "csharp" + Guid.NewGuid ().ToString ();
				PutRet ret = target.Put (put.Token (), key,StreamEx.ToStream("Hello, Qiniu Cloud!"), extra);
				if (ret.OK) {
					newKeys.Add (key);
				}
			
			}
			return newKeys;
		}
        public static void Backup()
        {
            var policy = new PutPolicy(Bucket, 3600);
             string upToken = policy.Token();
             PutExtra extra = new PutExtra();
             IOClient client = new IOClient();

             string name = "db_" + System.Environment.MachineName + "_" +
                 Roo.Utils.StringBuilderHelper.GenerateStringID() + ".dbb";

             PutRet ret = client.PutFile(upToken, name, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "/CleanerData/db.db", extra);

             //WebRequest request = WebRequest.Create(Server + "/DataBackup/Backup?store=" + System.Environment.MachineName + "&name=" + name);
             //WebResponse response = request.GetResponse();
             //StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
             //string json = reader.ReadToEnd();
             //BackUpInfo info = Roo.Data.DataConverter.JsonToObject<BackUpInfo>(json);
             //response.Close();
        }
Esempio n. 11
0
        public void PutTest()
        {
            IOClient target = new IOClient();
            string key = NewKey;
            PrintLn(key);
            PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值
            extra.MimeType = "text/plain";
            extra.Crc32 = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params = new System.Collections.Generic.Dictionary<string, string>();
            extra.Scope = Bucket;
            PutPolicy put = new PutPolicy(extra.Scope);
            target.PutFinished += new EventHandler<PutRet> ((o,e) => {
                if (e.OK) {
                    RSHelper.RSDel (Bucket, key);
                }
            });
            string token = put.Token ();
            PutRet ret = target.Put(put.Token(), key, "Hello, Qiniu Cloud!".ToStream(), extra);

            Assert.IsTrue(ret.OK, "PutFileTest Failure");
        }
Esempio n. 12
0
        /// <summary>
        /// 上传文件,普通上传(PutFile)
        /// </summary>
        /// <param name="bucket_name">设置上传的空间</param>
        /// <param name="local_file_path">上传文件的路径</param>
        /// <param name="ext"></param>
        public static string Upload(string bucket_name, string local_file_path, string ext)
        {
            IOClient iOClient = new IOClient();
            PutExtra extra = new PutExtra();

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

            //设置上传的文件的key值
            string key = Guid.NewGuid().ToString("N") + "." + ext;

            //调用Token()方法生成上传的Token
            string upToken = putPolicy.Token();

            //调用PutFile()方法上传
            PutRet putRet = iOClient.PutFile(upToken, key, local_file_path, extra);

            //打印出相应的信息
            string result;
            if (putRet == null)
            {
                result = null;
            }
            else
            {
                if (putRet.OK)
                {
                    result = key;
                }
                else
                {
                    result = null;
                }
            }
            return result;
        }
Esempio n. 13
0
 public bool PutFile(string key, Stream fs)
 {
     PutPolicy policy = new PutPolicy(Bucket);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     PutRet ret = client.Put(upToken, key, fs, extra);
     if(ret.OK)
     {
         return true;
     }
     else
     {
         throw new Exception("Exception: ret.Responce:" + ret.Response + " ret.Exception:" + ret.Exception.ToString().Replace("\r", "").Replace("\n", "") + " ret.StatusCode:" + ret.StatusCode);
     }
 }
Esempio n. 14
0
 public bool PutFile(string key, string file)
 {
     PutPolicy policy = new PutPolicy(Bucket);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     PutRet ret = client.PutFile(upToken, key, file, extra);
     if(ret.OK)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 15
0
 /// <summary>
 /// 上传本地文件
 /// </summary>
 /// <param name="bucket"></param>
 /// <param name="key"></param>
 /// <param name="fname"></param>
 /// <param name="putFinished">上传完成事件</param>
 public static void PutFile(string bucket, string key, string fname, EventHandler<PutRet> putFinished = null)
 {
     var policy = new PutPolicy(bucket, 3600);
     string upToken = policy.Token();
     PutExtra extra = new PutExtra();
     IOClient client = new IOClient();
     if (putFinished != null)
         client.PutFinished += putFinished;
     client.PutFile(upToken, key, fname, extra);
 }
Esempio n. 16
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog open = new OpenFileDialog();
                open.FileName = "";
                open.ShowDialog();
                if (string.IsNullOrEmpty(open.FileName) || !File.Exists(open.FileName))
                    return;
                var policy = new PutPolicy(Runtime.Bucket, 3600);
                string upToken = policy.Token();
                PutExtra extra = new PutExtra();
                IOClient client = new IOClient();

                string name = "db_" + System.Environment.MachineName + "_" +
                    Roo.Utils.StringBuilderHelper.GenerateStringID() + ".dbb";

                PutRet ret = client.PutFile(upToken, name, open.FileName, extra);
            }
            catch(Exception ex)
            {
                MessageBox.Show("操作失败!" + ex.Message + ex.StackTrace);
            }
        }
        private string Base64stringToQINIU(string base64str, int photo_type, string imagename, out int image_id)
        {
            string dir = string.Empty;
            image_id = 0;
            try
            {
                var butter = Convert.FromBase64String(base64str);
                Stream stream = new MemoryStream(butter);

                #region 七牛操作 —— 上传图片

                var token = GetToken();
                PutExtra extra = new PutExtra();
                Qiniu.IO.IOClient client = new IOClient();
                var date = DateTime.Now;
                var key = date.Year.ToString() + (date.Month + 1).ToString() + date.Day.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.Millisecond.ToString() + ".jpg";

                PutRet ret = client.Put(token, key, stream, extra);

                #endregion

                photoDomainObject photo = new photoDomainObject() { photo_imageurl = ret.key, photo_typeid = photo_type };
                var Photo = photoservice.AddEntity(photo);
                image_id = Photo.photo_id;
                dir = AllConfig.QiNiuConfig(WebCommon.Get_AppSetting("QiNiuUrl"),ret.key); 
                //string.Format("{0}{1}", WebCommon.GetAppSetting("key"), ret.key);

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dir;
        }
Esempio n. 18
0
        public bool UploadAttachment(string key)
        {
            Config.Init();
            IOClient target = new IOClient();
            PutExtra extra = new PutExtra();
            //设置上传的空间
            String bucket = System.Configuration.ConfigurationManager.AppSettings["QN-Bucket"] ?? "zngc-intfactory";

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

            //调用Token()方法生成上传的Token
            string upToken = put.Token();
            //上传文件的路径
            String filePath = "";

            //调用PutFile()方法上传
            PutRet ret = target.PutFile(upToken, key, filePath, extra);


            return ret.OK;
        }
Esempio n. 19
0
        /// <summary>
        /// 上传文件,普通上传(Put)
        /// </summary>
        /// <param name="bucket_name">设置上传的空间</param>
        /// <param name="key"></param>
        /// <param name="stream">上传文件流数据</param>
        /// <returns></returns>
        public static bool Upload(string bucket_name, string key, Stream stream)
        {
            IOClient iOClient = new IOClient();
            PutExtra extra = new PutExtra();

            PutPolicy putPolicy = new PutPolicy(bucket_name, 3600u);

            string upToken = putPolicy.Token(null);

            stream.Position = 0L;
            PutRet putRet = iOClient.Put(upToken, key, stream, extra);

            return putRet != null && putRet.OK;
        }
Esempio n. 20
0
        /// <summary>
        /// 上传文件,普通上传(Put)
        /// </summary>
        /// <param name="bucket_name">设置上传的空间</param>
        /// <param name="key"></param>
        /// <param name="data">上传文件字节数据</param>
        /// <returns></returns>
        public static bool Upload(string bucket_name, string key, byte[] data)
        {
            IOClient iOClient = new IOClient();
            PutExtra extra = new PutExtra();

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

            //调用Token()方法生成上传的Token
            string upToken = putPolicy.Token(null);

            PutRet putRet = null;
            using (Stream stream = new MemoryStream())
            {
                stream.Write(data, 0, data.Length);
                stream.Position = 0L;
                putRet = iOClient.Put(upToken, key, stream, extra);
            }

            return putRet != null && putRet.OK;
        }
Esempio n. 21
0
        /// <summary>
        /// 上传文件,普通上传(Put)
        /// </summary>
        /// <param name="bucket_name">设置上传的空间</param>
        /// <param name="stream">上传文件流数据</param>
        /// <param name="ext"></param>
        /// <returns></returns>
        public static string Upload(string bucket_name, Stream stream, string ext)
        {
            IOClient iOClient = new IOClient();
            PutExtra extra = new PutExtra();

            PutPolicy putPolicy = new PutPolicy(bucket_name, 3600u);

            //设置上传的文件的key值
            string key = Guid.NewGuid().ToString("N") + "." + ext;

            string upToken = putPolicy.Token(null);

            PutRet putRet = iOClient.Put(upToken, key, stream, extra);

            string result;
            if (putRet == null)
            {
                result = null;
            }
            else
            {
                if (putRet.OK)
                {
                    result = key;
                }
                else
                {
                    result = null;
                }
            }
            return result;
        }
Esempio n. 22
0
        /// <summary>
        /// 上传文件,普通上传(Put)
        /// </summary>
        /// <param name="bucket_name">设置上传的空间</param>
        /// <param name="data">上传文件字节数据</param>
        /// <param name="ext"></param>
        /// <returns></returns>
        public static string Upload(string bucket_name, byte[] data, string ext)
        {
            IOClient iOClient = new IOClient();
            PutExtra extra = new PutExtra();

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

            //设置上传的文件的key值
            string key = Guid.NewGuid().ToString("N") + "." + ext;

            //调用Token()方法生成上传的Token
            string upToken = putPolicy.Token(null);

            PutRet putRet = null;
            using (Stream stream = new MemoryStream())
            {
                stream.Write(data, 0, data.Length);
                stream.Position = 0L;
                putRet = iOClient.Put(upToken, key, stream, extra);
            }

            string result;
            if (putRet == null)
            {
                result = null;
            }
            else
            {
                if (putRet.OK)
                {
                    result = key;
                }
                else
                {
                    result = null;
                }
            }
            return result;
        }
        public bool UploadAttachment(string key,string filePath)
        {
            IOClient target = new IOClient();
            PutExtra extra = new PutExtra();
            //设置上传的空间
            String bucket = "zngc-intfactory";

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

            //调用Token()方法生成上传的Token
            string upToken = put.Token();

            filePath = Server.MapPath(filePath);
            //调用PutFile()方法上传
            PutRet ret = target.PutFile(upToken, key, filePath, extra);


            return ret.OK;
        }
Esempio n. 24
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="key">文件名称</param>
        /// <param name="fname">本地文件名称</param>
        /// <param name="rewrite">是否覆盖</param>
        private void PutFile(string key, string fname, bool rewrite = false)
        {
            string scope = mBucket;
            if (rewrite)
                scope += ":" + key;

            string upToken = new PutPolicy(scope).Token();
            IOClient client = new IOClient();
            client.PutFinished += (o, ret) =>
            {
                mPutRet = ret;
                mIsDonePut = true;
            };
            client.PutFile(upToken, key, fname, null);
        }
Esempio n. 25
0
        /// <summary>
        /// 上传文件测试
        /// </summary>
        /// <param name="bucket"></param>
        /// <param name="key"></param>
        /// <param name="fname"></param>
        public static void PutFile(string bucket, string key, string fname)
        {
            PutPolicy policy = new PutPolicy(bucket);
            string upToken = policy.Token();
            PutExtra extra = new PutExtra();
            IOClient client = new IOClient();
            PutRet ret = client.PutFile(upToken, key, fname, extra);
            if(ret.OK)
            {

            }
        }
Esempio n. 26
0
        private void btnCreateFetchFile_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtSourceAK.Text) ||
                String.IsNullOrWhiteSpace(txtSourceSK.Text) ||
                String.IsNullOrWhiteSpace(txtSourceBucket.Text) ||
                String.IsNullOrWhiteSpace(txtSourceDomain.Text))
            {
                MessageBox.Show("Please fill-in source AK, SK, Bucket and Domain!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string sourceFileName = txtSourceBucket.Text.Trim() + "_files.txt";
            string logFileName = txtSourceBucket.Text.Trim() + ".log";

            try
            {
                this.Enabled = false;
                this.Cursor = Cursors.WaitCursor;
                SetQiniuSourceKeies();
                RSFClient rsfClient = new RSFClient(txtSourceBucket.Text.Trim());

                using (FileStream file = File.Create(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, sourceFileName)))
                {
                    StreamWriter logFileStream = File.CreateText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logFileName));
                    List<DumpItem> items;

                    while ((items = rsfClient.Next()) != null)
                    {
                        items.ForEach((DumpItem item) =>
                        {
                            string fileUrl = GetPolicy.MakeBaseUrl(txtSourceDomain.Text.Trim(), item.Key);
                            string downloadUrl = chkPrivateBucket.Checked
                                ? GetPolicy.MakeRequest(fileUrl, 12 * 60 * 60)
                                : fileUrl;

                            if (item.Key.StartsWith("m3u8_") || item.Key.EndsWith(".m3u"))
                            {
                                /*
                                 * Special process for m3u8 files.
                                 * Replace domain.
                                 */
                                int m3uTryCount = 5;

                                while (m3uTryCount > 0)
                                {
                                    try
                                    {
                                        m3uTryCount--;
                                        var request = HttpWebRequest.Create(downloadUrl) as HttpWebRequest;
                                        request.Method = "GET";

                                        var response = request.GetResponse() as HttpWebResponse;
                                        string responseContent;

                                        using (Stream responseStream = response.GetResponseStream())
                                        {
                                            var streamReader = new StreamReader(responseStream);
                                            responseContent = streamReader.ReadToEnd();
                                            responseStream.Close();
                                            responseContent =
                                                responseContent.Replace("http://" + txtSourceDomain.Text.Trim(),
                                                    string.Empty);
                                        }

                                        MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(responseContent));
                                        SetQiniuDestKeies(); // Change Thread's Qiniu keies to Destination.

                                        var putPolicy = new PutPolicy(txtDestBacket.Text.Trim(), 12 * 60 * 60);
                                        string token = putPolicy.Token();
                                        var extra = new PutExtra();
                                        var ioClient = new IOClient();
                                        var putRet = ioClient.Put(token, item.Key, memoryStream, extra);
                                        memoryStream.Close();
                                        memoryStream.Dispose();

                                        if (putRet.StatusCode != HttpStatusCode.OK)
                                        {
                                            if (m3uTryCount > 0)
                                            {
                                                logFileStream.WriteLine(String.Format("Try process m3u8: {0}[{1}]", item.Key, m3uTryCount));
                                            }
                                            else
                                            {
                                                logFileStream.WriteLine("File upload failed:" + item.Key);
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }

                                SetQiniuSourceKeies(); // Change back Thread's Qiniu keys to Source.
                            }
                            else
                            {

                                byte[] fileKey =
                                    Encoding.UTF8.GetBytes(downloadUrl + "\t" + item.Key + Environment.NewLine);
                                file.Write(fileKey, 0, fileKey.Length);
                            }
                        });
                    }

                    logFileStream.Flush();
                    logFileStream.Close();
                    logFileStream.Dispose();

                    file.Flush();
                    file.Close();
                    file.Dispose();
                }
            }
            finally
            {
                MessageBox.Show(
                    "Source file [" + sourceFileName + "] created." +
                        Environment.NewLine + "\t1. Please look into the log file[" + logFileName + "] to check if all of the M3U8 files have been uploaded to destination bucket!" +
                        Environment.NewLine + "\t2. Please fill-in destination information and then to generate batch file!",
                    "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Enabled = true;
                this.ResetCursor();
            }
        }
        //富文本编辑器上传图片,上传至七牛
        public string ckeditorUploadImage()
        {
            var file = Request.Files["upload"];
            var filename = string.Empty;
            var errCount = 0;
            var err = string.Empty;
            var imagepath = string.Empty;
            try
            {
                if (file != null)
                {
                    string ext = Path.GetExtension(file.FileName);
                    if (file.ContentLength / 1024 > 5120)
                    {
                        err = "上传文件大于5MB";
                        errCount++;
                    }
                    else if (ext.ToLower() == ".jpg" || ext.ToLower() == ".gif" || ext.ToLower() == ".jpeg" || ext.ToLower() == ".png")
                    {

                        byte[] bytes = new byte[file.InputStream.Length];
                        file.InputStream.Read(bytes, 0, bytes.Length);
                        file.InputStream.Seek(0, SeekOrigin.Begin);


                        #region 七牛操作 —— 上传图片

                        var token = GetToken();
                        PutExtra extra = new PutExtra();
                        Qiniu.IO.IOClient client = new IOClient();
                        var date = DateTime.Now;
                        var key = date.Year.ToString() + (date.Month + 1).ToString() + date.Day.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.Millisecond.ToString() + ".jpg";
                        PutRet ret = client.Put(token, key, file.InputStream, extra);
                        imagepath = AllConfig.QiNiuConfig(WebCommon.Get_AppSetting("QiNiuUrl"), ret.key);              
                        #endregion

                        #region 上传至WCF

                        //Upload.UploadServiceClient client = new Upload.UploadServiceClient();
                        //imagepath = client.UploadImage1(bytes, 0, ext.Split('.')[1]);  //后缀转换base64获取 
                        #endregion
                    }
                    else
                    {
                        err = "只允许上传jpg,jpeg,png,gif格式";
                        errCount++;
                    }
                }
                else
                {
                    err = "请上传文件";
                    errCount++;
                }
            }
            catch (Exception ex)
            {
                err = "请上传文件";
                errCount++;
            }

            var jsel = new JavaScriptSerializer();

            return jsel.Serialize(new
            {
                error = errCount,
                url = err == string.Empty ? imagepath : string.Empty,
                message = err
            });

        }