예제 #1
0
파일: UPYun.cs 프로젝트: radtek/SharedCode
        /// <summary>
        /// 上传图片到又拍云
        /// </summary>
        /// <param name="imageUri">上传的图片的本地位置</param>
        /// <param name="location">位置(如:/a/b/c.jpg)</param>
        public static bool UploadIamge(string imageUri, string location)
        {
            UpYun        upyun   = new UpYun(_spaceName, _operator, _password);
            Hashtable    headers = new Hashtable();
            FileStream   fs      = new FileStream(imageUri, FileMode.Open, FileAccess.Read);
            BinaryReader r       = new BinaryReader(fs);

            byte[] postArray = r.ReadBytes((int)fs.Length);
            upyun.setContentMD5(UpYun.md5_file(imageUri));
            return(upyun.writeFile(location, postArray, true));
        }
예제 #2
0
파일: UPYun.cs 프로젝트: radtek/SharedCode
        /// <summary>
        /// 上传图片到又拍云
        /// </summary>
        /// <param name="inputStream">图片的输入流</param>
        /// <param name="location">位置(如:/a/b/c.jpg)</param>
        public static bool UploadIamge(Stream inputStream, string location)
        {
            UpYun        _upyun  = new UpYun(_spaceName, _operator, _password);
            Hashtable    headers = new Hashtable();
            BinaryReader r       = new BinaryReader(inputStream);

            byte[] bytes = new byte[inputStream.Length];
            inputStream.Read(bytes, 0, bytes.Length);
            // 设置当前流的位置为流的开始
            inputStream.Seek(0, SeekOrigin.Begin);

            byte[] postArray = r.ReadBytes((int)inputStream.Length);
            //_upyun.setContentMD5(UpYun.md5_file("Hello, this is a f*****g image."));
            return(_upyun.writeFile(location.ToLower(), postArray, true));
        }