예제 #1
0
        public PutFileRet PutFile(string key, string mimeType, string localFile, string customMeta)
        {
            string entryURI = BucketName + ":" + key;

            if (String.IsNullOrEmpty(mimeType))
            {
                mimeType = "application/octet-stream";
            }
            string url = Config.IO_HOST + "/rs-put/" + Base64UrlSafe.Encode(entryURI) +
                         "/mimeType/" + Base64UrlSafe.Encode(mimeType);

            if (!String.IsNullOrEmpty(customMeta))
            {
                url += "/meta/" + Base64UrlSafe.Encode(customMeta);
            }

            try
            {
                using (FileStream fs = File.OpenRead(localFile))
                {
                    CallRet callRet = Conn.CallWithBinary(url, mimeType, fs, fs.Length);
                    return(new PutFileRet(callRet));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(new PutFileRet(new CallRet(HttpStatusCode.BadRequest, e)));
            }
        }