Exemplo n.º 1
0
        public static string Upload(string url, UploadFile[] files, NameValueCollection form)
        {
            HttpWebResponse resp = Upload((HttpWebRequest)WebRequest.Create(url), files, form);

            using (Stream s = resp.GetResponseStream())
            using (StreamReader sr = new StreamReader(s))
            {
                return sr.ReadToEnd();
            }
        }
Exemplo n.º 2
0
        //Send the sound of filepath to SoundCloud on the account described by the username & the password
        public void SoundCloudUploadFile(string username, string password, string filePath, string title, string fileName)
        {
            _username = username;
            _password = password;
            string token = this.GetToken();
            if (token != "")
            {
                try
                {
                    //On prépare la requète avec différents paramètres
                    var request = WebRequest.Create(_soundCloudTracksRes) as HttpWebRequest;
                    request.Accept = "*/*";
                    request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
                    request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
                    request.Headers.Add("Accept-Language", "en-US,en;q=0.8,ru;q=0.6");

                    //On envoit la requète sur le end point tracks avec les params requis par l'API
                    var files = new UploadFile[]{
                    new UploadFile(filePath, "track[asset_data]", "application/octet-stream")
                };

                    var form = new NameValueCollection();
                    form.Add("track[title]", title);
                    form.Add("oauth_token", token);
                    form.Add("format", "json");

                    form.Add("Filename", fileName);
                    form.Add("Upload", "Submit Query");

                    try
                    {
                        using (var response = HttpUploadHelper.Upload(request, files, form))
                        {
                            using (var reader = new StreamReader(response.GetResponseStream()))
                            {

                            }
                        }
                    }
                    catch
                    {

                    }
                }catch{
                }
            }
        }
Exemplo n.º 3
0
        public static HttpWebResponse Upload(HttpWebRequest req, UploadFile[] files, NameValueCollection form)
        {
            List<MimePart> mimeParts = new List<MimePart>();

            try
            {
                foreach (string key in form.AllKeys)
                {
                    StringMimePart part = new StringMimePart();

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + key + "\"";
                    part.StringData = form[key];

                    mimeParts.Add(part);
                }

                int nameIndex = 0;

                foreach (UploadFile file in files)
                {
                    StreamMimePart part = new StreamMimePart();

                    if (string.IsNullOrEmpty(file.FieldName))
                        file.FieldName = "file" + nameIndex++;

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + file.FieldName + "\"; filename=\"" + file.FileName + "\"";
                    part.Headers["Content-Type"] = file.ContentType;

                    part.SetStream(file.Data);

                    mimeParts.Add(part);
                }

                string boundary = "----------" + DateTime.Now.Ticks.ToString("x");

                req.ContentType = "multipart/form-data; boundary=" + boundary;
                req.Method = "POST";

                long contentLength = 0;

                byte[] _footer = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");

                foreach (MimePart part in mimeParts)
                {
                    contentLength += part.GenerateHeaderFooterData(boundary);
                }

                req.ContentLength = contentLength + _footer.Length;

                byte[] buffer = new byte[8192];
                byte[] afterFile = Encoding.UTF8.GetBytes("\r\n");
                int read;

                using (Stream s = req.GetRequestStream())
                {
                    foreach (MimePart part in mimeParts)
                    {
                        s.Write(part.Header, 0, part.Header.Length);

                        while ((read = part.Data.Read(buffer, 0, buffer.Length)) > 0)
                            s.Write(buffer, 0, read);

                        part.Data.Dispose();

                        s.Write(afterFile, 0, afterFile.Length);
                    }

                    s.Write(_footer, 0, _footer.Length);
                }

                return (HttpWebResponse)req.GetResponse();
            }
            catch
            {
                foreach (MimePart part in mimeParts)
                    if (part.Data != null)
                        part.Data.Dispose();

                throw;
            }
        }
Exemplo n.º 4
0
        public static HttpWebResponse Upload(HttpWebRequest req, UploadFile[] files, NameValueCollection form, Action<int> progress)
        {
            req.Timeout = int.MaxValue; //Maximum timeout
            req.ReadWriteTimeout = int.MaxValue;
            req.AllowWriteStreamBuffering = false;

            List<MimePart> mimeParts = new List<MimePart>();

            try
            {
                foreach (string key in form.AllKeys)
                {
                    StringMimePart part = new StringMimePart();

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + key + "\"";
                    part.StringData = form[key];

                    mimeParts.Add(part);
                }

                int nameIndex = 0;

                foreach (UploadFile file in files)
                {
                    StreamMimePart part = new StreamMimePart();

                    if (string.IsNullOrEmpty(file.FieldName))
                        file.FieldName = "file" + nameIndex++;

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + file.FieldName + "\"; filename=\"" + file.FileName + "\"";
                    part.Headers["Content-Type"] = file.ContentType;

                    part.SetStream(file.Data);

                    mimeParts.Add(part);
                }

                string boundary = "----------" + DateTime.Now.Ticks.ToString("x");

                req.ContentType = "multipart/form-data; boundary=" + boundary;
                req.Method = "POST";

                long contentLength = 0;

                byte[] _footer = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");

                foreach (MimePart part in mimeParts)
                {
                    contentLength += part.GenerateHeaderFooterData(boundary);
                }

                req.ContentLength = contentLength + _footer.Length;

                byte[] buffer = new byte[8192];
                byte[] afterFile = Encoding.UTF8.GetBytes("\r\n");
                int read;

                decimal sent = 0;
                using (Stream s = req.GetRequestStream())
                {
                    foreach (MimePart part in mimeParts)
                    {
                        s.Write(part.Header, 0, part.Header.Length);

                        while ((read = part.Data.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            s.Write(buffer, 0, read);
                            sent += buffer.Length;
                            progress((int) Math.Round((sent / req.ContentLength) * 100));
                            //TODO Something here is causing miscalculation in total data to be sent!
                            //Console.WriteLine("MB sent: " + Math.Round(sent / (1024 * 1024) , 2) + " - Percent: " + Math.Round((sent / req.ContentLength) * 100, 2) + "%");
                        }

                        part.Data.Dispose();

                        s.Write(afterFile, 0, afterFile.Length);
                    }

                    s.Write(_footer, 0, _footer.Length);
                }

                req.KeepAlive = false; //Request gets canceled otherwise
                return (HttpWebResponse)req.GetResponse();
            }
            catch
            {
                foreach (MimePart part in mimeParts)
                    if (part.Data != null)
                        part.Data.Dispose();

                throw;
            }
        }
        public static void Upload(HttpWebRequest req, UploadFile[] files, NameValueCollection form, AsyncCallback callback)
        {
            List<MimePart> mimeParts = new List<MimePart>();

            //try
            //{
                foreach (string key in form.AllKeys)
                {
                    StringMimePart part = new StringMimePart();

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + key + "\"";
                    part.StringData = form[key];

                    mimeParts.Add(part);
                }

                int nameIndex = 0;

                foreach (UploadFile file in files)
                {
                    StreamMimePart part = new StreamMimePart();

                    if (string.IsNullOrEmpty(file.FieldName))
                        file.FieldName = "file" + nameIndex++;

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + file.FieldName + "\"; filename=\"" + file.FileName + "\"";
                    part.Headers["Content-Type"] = file.ContentType;

                    part.SetStream(file.Data);

                    mimeParts.Add(part);
                }

                string boundary = "----------" + DateTime.Now.Ticks.ToString("x");

                req.ContentType = "multipart/form-data; boundary=" + boundary;
                req.Method = "POST";

                long contentLength = 0;

                byte[] _footer = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");

                foreach (MimePart part in mimeParts)
                {
                    contentLength += part.GenerateHeaderFooterData(boundary);
                }

                req.ContentLength = contentLength + _footer.Length;

                byte[] buffer = new byte[8192];
                byte[] afterFile = Encoding.UTF8.GetBytes("\r\n");
                int read;

                using (Stream s = req.GetRequestStream())
                {
                    foreach (MimePart part in mimeParts)
                    {
                        s.Write(part.Header, 0, part.Header.Length);

                        while ((read = part.Data.Read(buffer, 0, buffer.Length)) > 0)
                            s.Write(buffer, 0, read);

                        part.Data.Dispose();

                        s.Write(afterFile, 0, afterFile.Length);
                    }

                    s.Write(_footer, 0, _footer.Length);
                }

                req.KeepAlive = false; //Request gets canceled otherwise
                req.Timeout = System.Threading.Timeout.Infinite;
                req.ReadWriteTimeout = System.Threading.Timeout.Infinite;
                req.ProtocolVersion = HttpVersion.Version10;
                req.AllowWriteStreamBuffering = false;
                req.BeginGetResponse(callback, null);
            /*}
            catch
            {
                foreach (MimePart part in mimeParts)
                    if (part.Data != null)
                        part.Data.Dispose();

                throw;
            }*/
        }
 public static void Upload(string url, UploadFile[] files, NameValueCollection form, AsyncCallback callback)
 {
     Upload((HttpWebRequest)WebRequest.Create(url), files, form, callback);
 }
Exemplo n.º 7
0
        public static HttpWebResponse Upload(HttpWebRequest req, UploadFile[] files, NameValueCollection form)
        {
            List<MimePart> mimeParts = new List<MimePart>();

            try
            {
                foreach (string key in form.AllKeys)
                {
                    StringMimePart part = new StringMimePart();

                    part.Headers["Content-Disposition"] = "form-data; name=\"" + key + "\"";
                    part.StringData = form[key];

                    mimeParts.Add(part);
                }

                int nameIndex = 0;

                foreach (UploadFile file in files)
                {
                    StreamMimePart part = new StreamMimePart();

                    if (string.IsNullOrEmpty(file.FieldName))
                        file.FieldName = "file" + nameIndex++;

                    //part.Headers["Content-Disposition"] = "form-data; name=\"" + file.FieldName + "\"; filename=\"" + file.FileName + "\"";
                    part.Headers["Content-Type"] = file.ContentType;
                    //part.Headers["Content-Transfer-Encoding"] = "8bit";
                    if (nameIndex < 1)
                    {
                        part.Headers["Content-ID"] = "<*****@*****.**>";
                        //part.Headers["Content-Transfer-Encoding"] = "base64";
                    }

                    part.SetStream(file.Data);

                    mimeParts.Add(part);
                }

                //string boundary = "----=_Part_0_" + DateTime.Now.Ticks.ToString("x");
                string boundary = "----=_Part_0_2535725.1277885346844";

                // req.ContentType = "multipart/form-data; boundary=" + boundary;
                req.ContentType = "Multipart/Related; type=\"text/xml\"; charset=utf-8; boundary=\"" + boundary + "\"; start=\"<*****@*****.**>\"";
                //req.ContentType = "multipart/related; boundary=\"" + boundary + "\"";
                req.Method = "POST";
                req.Headers["MIME-Version"] = "1.0";

                long contentLength = 0;

                byte[] _footer = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");

                foreach (MimePart part in mimeParts)
                {
                    contentLength += part.GenerateHeaderFooterData(boundary);
                }

                byte[] buffer = new byte[8192];
                byte[] afterFile = Encoding.UTF8.GetBytes("\r\n");
                int read;

                req.ContentLength = contentLength + _footer.Length + afterFile.Length;
                //req.ContentLength = 3326;

                using (Stream s = req.GetRequestStream())
                {
                    s.Write(afterFile, 0, afterFile.Length);
                    foreach (MimePart part in mimeParts)
                    {
                        s.Write(part.Header, 0, part.Header.Length);

                        while ((read = part.Data.Read(buffer, 0, buffer.Length)) > 0)
                            s.Write(buffer, 0, read);

                        part.Data.Dispose();

                        s.Write(afterFile, 0, afterFile.Length);
                    }

                    s.Write(_footer, 0, _footer.Length);
                }

                return (HttpWebResponse)req.GetResponse();
            }
            catch
            {
                foreach (MimePart part in mimeParts)
                    if (part.Data != null)
                        part.Data.Dispose();

                throw;
            }
        }
        private UploadResponse UploadTrack(Stream data, string token, string title, string filename)
        {
            System.Net.ServicePointManager.Expect100Continue = false;
            var request = WebRequest.Create("https://api.soundcloud.com/tracks") as HttpWebRequest;
            //some default headers
            request.Accept = "*/*";
            request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
            request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
            request.Headers.Add("Accept-Language", "en-US,en;q=0.8,ru;q=0.6");

            //file array
            var files = new UploadFile[] {
                new UploadFile(data, "track[asset_data]", filename, "application/octet-stream")
            };
            //other form data
            var form = new NameValueCollection();
            form.Add("track[title]", title);
            form.Add("track[sharing]", "private");
            form.Add("oauth_token", token);
            form.Add("format", "json");

            form.Add("Filename", filename);
            form.Add("Upload", "Submit Query");
            try
            {
                using (var response = HttpUploadHelper.Upload(request, files, form))
                {
                    using (var reader = new StreamReader(response.GetResponseStream()))
                    {
                        return JsonConvert.DeserializeObject<UploadResponse>(reader.ReadToEnd());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        // upload a file using the MediaWiki upload API
        private void UploadFile(string editToken, LoginInfo loginInfo, string localFilePath, string remoteFilename)
        {
            UploadFile[] files = new UploadFile[] { new UploadFile(localFilePath, "file", "application/octet-stream") };

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(GetApiUrl());
            request.CookieContainer = loginInfo.Cookies;

            var parameters = new System.Collections.Specialized.NameValueCollection();
            parameters["format"] = "xml";
            parameters["action"] = "upload";
            parameters["filename"] = Path.GetFileName(localFilePath);
            parameters["token"] = editToken;

            var response = HttpUploadHelper.Upload(request, files, parameters);

            string strResponse = new StreamReader(response.GetResponseStream()).ReadToEnd();
            if (strResponse.StartsWith("unknown_action"))
            {
                // fallback : upload using web form
                UploadFileThroughForm(loginInfo, localFilePath, remoteFilename);
                return;
            }

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(strResponse);
                var element = xmlDoc.GetElementsByTagName("api")[0].ChildNodes[0];
                if (element.Name == "error")
                {
                    string errorCode = element.Attributes["code"].Value;
                    string errorMessage = element.Attributes["info"].Value;
                    throw new MediaWikiException("Error uploading to MediaWiki: " + errorCode + "\r\n" + errorMessage);
                }
                string result = element.Attributes["result"].Value;
                if (result == "Warning")
                {
                    foreach (XmlNode child in element.ChildNodes)
                    {
                        if (child.Name == "warnings")
                        {
                            if (child.Attributes["exists"] != null)
                            {
                                string existingImageName = child.Attributes["exists"].Value;
                                throw new MediaWikiException("Image already exists on the wiki: " + existingImageName);
                            }
                        }
                    }
                }

                if (result != "Success")
                    throw new MediaWikiException("Error uploading to MediaWiki:\r\n" + result);
            }
            catch (XmlException)
            {
                throw new MediaWikiException("Unexpected answer while uploading:\r\n" + strResponse);
            }
        }
Exemplo n.º 10
0
        // upload a file using the web form instead of the API (for old versions of WikiMedia which don't have the upload API)
        private void UploadFileThroughForm(LoginInfo loginInfo, string localFilePath, string remoteFilename)
        {
            UploadFile[] files = new UploadFile[] { new UploadFile(localFilePath, "wpUploadFile", "application/octet-stream") };

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(GetUrl("Special:Upload"));
            request.CookieContainer = loginInfo.Cookies;

            var parameters = new System.Collections.Specialized.NameValueCollection();
            parameters["wpSourceType"] = "file";
            parameters["wpDestFile"] = remoteFilename;
            parameters["wpUpload"] = "Upload file";

            var response = HttpUploadHelper.Upload(request, files, parameters);

            string strResponse = new StreamReader(response.GetResponseStream()).ReadToEnd();
            if (strResponse.Contains("A file with this name exists already"))
                throw new MediaWikiException("Image already exists on the wiki");
        }
Exemplo n.º 11
0
        private void editMetin_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Resim Seç";
            ofd.Filter = "Resim Dosyaları | *.jpg; *.jpeg; *.jpe; *.png; *.gif";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                NameValueCollection postData = new NameValueCollection();
                postData.Add("Id", "0");
                postData.Add("ClassName", "Content");
                postData.Add("Title", "DEL "+DateTime.Now.Ticks);
                postData.Add("SpotTitle", "");
                postData.Add("Description", "");
                postData.Add("Tags", "");
                postData.Add("PublishDate", DateTime.Now.ToString("dd.MM.yyyy"));
                postData.Add("Metin", "");
                postData.Add("IsManset", "0");

                string res = "";

                var files = new UploadFile[1];
                files[0] = new UploadFile(ofd.FileName, "Picture", "image/jpg");

                var s = Settings.Load();

                res = HttpUploadHelper.Upload(s.SiteAddress[Index].Trim('/') + "/UploadContent.ashx", files, postData);

                Content c = JsonConvert.DeserializeObject<Content>(res);
                editMetin.SelectionLength = 0;
                editMetin.SelectedText = string.Format("<img src=\"{0}\"/>", c.Picture);

                using (WebClient wc = new WebClient())
                {
                    wc.Encoding = Encoding.UTF8;
                    string res2 = wc.DownloadString(s.SiteAddress[Index].Trim('/') + string.Format("/DoCommand.ashx?method=deleteContents&Email={0}&Passwd={1}&ids={2}", s.Emails[Index], s.Passwords[Index], c.Id.ToString()));
                }

            }
        }
Exemplo n.º 12
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            NameValueCollection postData = getContentDataAsNameValue();
            if (CurrentContentId == 0)
                postData["Metin"] = postData["Metin"];

            string res = "";

            if (PictureChanged)
            {
                var files = new UploadFile[1];
                files[0] = new UploadFile(editPicture.Tag.ToString(), "Picture", "image/jpg");

                res = HttpUploadHelper.Upload(Settings.Load().SiteAddress[Index].Trim('/') + "/UploadContent.ashx", files, postData);
            }
            else
            {
                res = HttpUploadHelper.Upload(Settings.Load().SiteAddress[Index].Trim('/') + "/UploadContent.ashx", new UploadFile[0], postData);
            }

            Content c = JsonConvert.DeserializeObject<Content>(res);
            CurrentContentId = c.Id;
            if (!string.IsNullOrWhiteSpace(c.Picture))
            {
                PictureChanged = false;
                editPicture.ImageLocation = Settings.Load().SiteAddress[Index].Trim('/') + c.Picture;
                editPicture.Refresh();
            }

            MessageBox.Show("Kaydedildi (Id: " + CurrentContentId + ")", "Cinar CMS Desktop Editor");
        }
Exemplo n.º 13
0
        public static string UploadFilesToRemoteUrl(string url, string fileName, string filePath)
        {
            var files = new UploadFile[] 
            { 
                new UploadFile(filePath, fileName, "image/jpeg")
            };

            NameValueCollection form = new NameValueCollection();

            string response = HttpUploadHelper.Upload(url, files, form);

            return response;
            /* HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

             string boundary = Guid.NewGuid().ToString().Replace("-","");
             req.ContentType = "multipart/form-data; boundary=" +boundary;
             req.Method = "POST";

             using (var postData = new MemoryStream())
             {
                 string newLine = "\r\n";
                 StreamWriter sw = new StreamWriter(postData);
                 sw.Write("--" + boundary + newLine);
                 sw.Write("Content-Disposition: form-data;name=\"{0}\";filename=\"{1}\"{2}", "fileName", Path.GetFileName(filePath), newLine);
                 sw.Write("Content-Type: image/pjpeg " + newLine + newLine);
                 sw.Flush();

                 using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                 {
                     byte[] buffer = new byte[1024];
                     int bytesRead = 0;
                     while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                     {
                         postData.Write(buffer, 0, bytesRead);
                     }
                     fileStream.Close();
                 }

                 sw.Write(newLine);
                 sw.Write("--{0}--{1}", boundary,
                 newLine);
                 sw.Flush();

                 req.ContentLength = postData.Length;
                 using (Stream s = req.GetRequestStream())
                 {
                     postData.WriteTo(s);
                 }
                 postData.Close();
             }

             WebResponse webResponse = req.GetResponse();

             Stream responceStream = webResponse.GetResponseStream();
             Encoding enc = System.Text.Encoding.UTF8;
             StreamReader loResponseStream = new StreamReader(webResponse.GetResponseStream(), enc);

             string Response = loResponseStream.ReadToEnd();
             webResponse.Close();
             req = null;
             webResponse = null;
             */

        }
Exemplo n.º 14
0
        /// <summary>
        /// Upload file to server.
        /// </summary>
        /// <param name="filepath">Path to the file to upload.</param>
        /// <param name="token">Upload token.</param>
        public static void Upload(string filepath, Token token)
        {
            //Library from http://aspnetupload.com/Upload-File-POST-HttpWebRequest-WebClient-RFC-1867.aspx
            //string url = HOST + "/upload";
            //ProgressForm.Instance.BeginInvoke(new Action(() => { ProgressForm.Instance.Show(); }), null);

            ProgressForm.Show();

            bool tryagain = false;
            do
            {
                try
                {
                    string url = "http://qpaste.s3.amazonaws.com/";
                    UploadFile[] files = new UploadFile[]
                    {
                        new UploadFile(filepath, "file", token.storage.s3Policy.conditions.mime)
                    };
                    NameValueCollection form = new NameValueCollection();
                    form["key"] = token.storage.s3Policy.conditions.key;
                    form["AWSAccessKeyId"] = token.storage.s3Key;
                    form["Policy"] = token.storage.s3PolicyBase64;
                    form["Signature"] = token.storage.s3Signature;
                    form["Bucket"] = token.storage.s3Policy.conditions.bucket;
                    form["acl"] = token.storage.s3Policy.conditions.acl;
                    form["Content-Type"] = token.storage.s3Policy.conditions.mime;
                    form["Content-Disposition"] = token.storage.s3Policy.conditions.disposition;

                    string response = Krystalware.UploadHelper.HttpUploadHelper.Upload(url, files, form, new Action<int>((int progress) => {
                        ProgressForm.Value = progress;
                    }));
                    UploadDone(token.token);

                    tryagain = false;
                }
                catch
                {
                    //string output = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    //Console.WriteLine("Exception, suck it");
                    DialogResult result = MessageBox.Show("An error occurred when qPaste was uploading your file!\nDo you want to try again?",
                        "Upload error",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Error);

                    tryagain = result.Equals(DialogResult.Yes);
                }
            } while (tryagain);

            ProgressForm.Hide();
        }
Exemplo n.º 15
0
        internal static void CreateCollection(Collection Collection)
        {
            Stream FileStream = new MemoryStream();

            Collection.Artwork.Save(FileStream, System.Drawing.Imaging.ImageFormat.Jpeg);

            FileStream.Seek(0, SeekOrigin.Begin);

            UploadFile Artwork = new UploadFile(FileStream, "Artwork", "artwork.jpg", "image/jpg");

            UploadFile[] Files = new UploadFile[1];
            Files[0] = Artwork;

            HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("http://localhost:32400/manage/collections/add");
            Request.Proxy = new WebProxy("localhost", 8888);
            Request.ServicePoint.Expect100Continue = false;
            Request.KeepAlive = false;
            Request.Timeout = 1000 * 60 * 10;
            HttpWebResponse Response = HttpUploadHelper.Upload(Request, Files, Collection.ToNameValueCollection());
        }