protected void btnSave_Click(object sender, EventArgs e)
    {
        sponsor.Name = txbName.Text;
        if (fupLogo.PostedFile.ContentLength > 0)
        {
            Uploader uploader = new Uploader();
            sponsor.ImageURL = uploader.UploadImage(fupLogo.PostedFile,
                                                   MapPath("~") + @"Images\Sponsor\",
                                                   0,
                                                   false);
        }
        sponsor.Text = txbText.Text;
        sponsor.LinkTo = txbLinkTo.Text;

        if (Convert.ToInt32(Request.QueryString["ID"]) > 0)
        {
            sponsorFac.Update(sponsor);

        }
        else if (Request.QueryString["NewItem"] == "true")
        {
            sponsorFac.Add(sponsor);
        }

        string currentURL = Request.RawUrl;
        Response.Redirect(currentURL);
    }
示例#2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        member.TeamMemberName = txbName.Text;
        if (fupPortrait.PostedFile.ContentLength > 0)
        {
            Uploader uploader = new Uploader();
            member.TeamImageURL = uploader.UploadImage(fupPortrait.PostedFile,
                                                       MapPath("~") + @"Images\Team\",
                                                       250,
                                                       false);
        }
        member.TeamMemberDescription = txbDescription.Text;
        member.TeamMemberEmail = txbContactEmail.Text;

        if (Convert.ToInt32(Request.QueryString["ID"]) > 0)
        {
            teamFac.Update(member);
        }
        else if (Request.QueryString["NewItem"] == "true")
        {
            teamFac.Add(member);
        }


        string currentURL = Request.RawUrl;
        Response.Redirect(currentURL);
    }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentEncoding = System.Text.Encoding.UTF8;
            //上传配置
            string pathbase = "upload/";                                                          //保存路径
            int size = 10;                     //文件大小限制,单位mb                                                                                   //文件大小限制,单位KB
            string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };                    //文件允许格式

            string callback = context.Request["callback"];
            string editorId = context.Request["editorid"];

            //上传图片
            Hashtable info;
            Uploader up = new Uploader();
            info = up.upFile(context, pathbase, filetype, size); //获取上传状态
            string json = BuildJson(info);

            context.Response.ContentType = "text/html";
            if (callback != null)
            {
                context.Response.Write(String.Format("<script>{0}(JSON.parse(\"{1}\"));</script>", callback, json));
            }
            else
            {
                context.Response.Write(json);
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            string filename = string.Empty;
            bool showHelp = false;

            var options = new OptionSet()
                              {
                                  { "filename=|f=", "File to upload",(v) => filename = v },
                                  { "help|h", "Show help",(v) => showHelp = true }
                              };
            options.Parse(args);

            if(string.IsNullOrEmpty(filename) || showHelp)
            {
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            if (!File.Exists(filename))
            {
                Console.WriteLine("File does not exist. Exiting...");
                return;
            }

            var settings = ConfigurationManager.AppSettings;

            var configuration = new AccountConfiguration(settings["cloudinary.cloud"],
                                                         settings["cloudinary.apikey"],
                                                         settings["cloudinary.apisecret"]);

            var uploader = new Uploader(configuration);

            string publicId = Path.GetFileNameWithoutExtension(filename);

            using(var stream =new FileStream(filename, FileMode.Open))
            {
                var uploadResult = uploader.Upload(new UploadInformation(filename, stream)
                                    {
                                        PublicId = publicId,
                                        Transformation = new Transformation(120, 120)
                                                             {
                                                                 Crop = CropMode.Scale
                                                             },
                                        Eager = new[]
                                                    {
                                                        new Transformation(240, 240),
                                                        new Transformation(120, 360) { Crop = CropMode.Limit },
                                                    }
                                    });

                Console.WriteLine("Version: {0}, PublicId {1}", uploadResult.Version, uploadResult.PublicId);
                Console.WriteLine("Url: {0}", uploadResult.Url);
            }
            Console.WriteLine("Successfully uploaded file");

            uploader.Destroy(publicId);

            if(Debugger.IsAttached)
                Console.ReadLine();
        }
示例#5
0
		public Page()
		{
			InitializeComponent();

			_uploader = new Uploader(_website + "FileUploadService.asmx");
			testTree.BuildRoot();

			_uploader.UploadProgressChange += new UploadEventHandler(Uploader_UploadProgressChange);
			_uploader.UploadFinished += new UploadEventHandler(Uploader_UploadFinished);
		}
		protected void ExecuteUpload(IExecuteFlickrUploaderWorkflowMessage message, Flickr flickr, FileInfo inputFilePath)
		{
			var cancellationTokenSource = new CancellationTokenSource();
			var cancellationToken = cancellationTokenSource.Token;

			var task = Task.Factory.StartNew(() => { });
			task.ContinueWith((t) =>
			{
				if (!cancellationToken.IsCancellationRequested)
				{
					FlickrUploaderService.Uploaders.Add(message, new CancellableTask
					{
						Task = task,
						CancellationTokenSource = cancellationTokenSource
					});

                    var asyncUploadSettings = new AsyncUploadSettings
                    {
                        Message = message,
                        InputStream = inputFilePath.OpenRead()
                    };

				    var uploader = new Uploader(asyncUploadSettings);

                    flickr.OnUploadProgress += uploader.OnUploadProgress;

                    flickr.UploadPictureAsync(asyncUploadSettings.InputStream, inputFilePath.Name,
                                message.Settings.MetaData.Title,
                                message.Settings.MetaData.Description,
                                message.Settings.MetaData.Keywords,
                                message.Settings.MetaData.IsPublic,
                                message.Settings.MetaData.IsFamily,
                                message.Settings.MetaData.IsFriend,
                                message.Settings.MetaData.ContentType,
                                message.Settings.MetaData.SafetyLevel,
                                message.Settings.MetaData.HiddenFromSearch, 
                                result =>
                                    {
                                        FlickrUploaderService.Uploaders.Remove(message);
                                        uploader.OnUploadCompleted(result);
                                    } 
                                );
				}
				cancellationToken.ThrowIfCancellationRequested();
			}
				, cancellationToken);
		}
示例#7
0
        public ActionResult Upload(int id, HttpPostedFileBase fil)
        {
            if (fil != null)
            {
                Uploader u = new Uploader();
                string path = Request.PhysicalApplicationPath + "Content/Images/";
                string file = u.UploadImage(fil, path, 300, true);

                BilledFac bf = new BilledFac();
                Billede b = new Billede();
                b.Filnavn = Path.GetFileName(file);
                b.PostID = id;
                bf.Insert(b);

            }

            return View("Index", postFac.GetIndexData());
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Uploader uploader = new Uploader();

        comp.CompanyName = txbName.Text;
        if (fupLogo.PostedFile.ContentLength > 0)
        {
            comp.CompanyImageURL = uploader.UploadImage(fupLogo.PostedFile,
                                                        MapPath("~") + @"Images\Company\" +
                                                        comp.CompanyName + @"\",
                                                        250,
                                                        false);
        }
        if (fupBanner.PostedFile.ContentLength > 0)
        {
            comp.CompanyImageBannerURL = uploader.UploadImage(fupBanner.PostedFile,
                                                        MapPath("~") + @"Images\Company\" +
                                                        comp.CompanyName + @"\",
                                                        2000,
                                                        false);
        }
        comp.CompanyDescription = txbCompanyText.Text;
        comp.CompanyAcceptWork = chbAcceptWork.Checked;
        comp.CompanySalesPitch = txbSalesPitch.Text;
        comp.CompanyWebsite = txbWebsite.Text;
        comp.CompanyContactEmail = txbContactEmail.Text;

        if (Convert.ToInt32(Request.QueryString["ID"]) > 0)
        {
            companyFac.Update(comp);

        }
        else if (Request.QueryString["NewItem"] == "true")
        {
            companyFac.Add(comp);
        }



        string currentURL = Request.RawUrl;
        Response.Redirect(currentURL);
    }
示例#9
0
        public void SaveLogo()
        {
            Group group = ctx.owner.obj as Group;

            Result result = Uploader.SaveGroupLogo(ctx.GetFileSingle(), group.Url);

            if (result.HasErrors)
            {
                errors.Join(result);
                run(Logo);
            }
            else
            {
                group.Logo = result.Info.ToString();
                db.update(group, "Logo");
                log(SiteLogString.UpdateGroupLogo(), group);

                echoRedirect(lang("opok"));
            }
        }
示例#10
0
        private async Task DoUpload()
        {
            Uploader uploader = (Uploader)_captureController.Session.Uploader;

            if (uploader != null && uploader.InProgress)
            {
                _appController.TryCancelUpload();

                this.Dispatcher.Invoke(() =>
                {
                    btnEndAndStartNewSession.IsEnabled = true;
                });
            }
            else if (!_captureController.Session.Compressing)
            {
                _captureController.Logger.info("Start Uploading: " + _captureController.Session.CompressedScanFile);
                _cameraImagePresenter.Enabled = false;
                await _appController.CompressAndUploadAndStartNewSession();
            }
        }
        private static void AddPhotosToPhotoset(string photosetName, string photosetId, List <string> photoIds)
        {
            Console.WriteLine();
            Logger.Info("Moving uploaded files to the photoset...");
            //todo: move to FlickrService
            var fails = FlickrService.ParallelExecute(photoIds, id => Uploader.AddPictureToPhotoSet(id, photosetId), Settings.BatchSizeForParallelProcessing);

            if (!fails.Any())
            {
                Logger.Info("Uploaded pictures were successfully moved to '{0}'.", photosetName);
            }
            else
            {
                Logger.Error("Moved with errors:");
                foreach (var fail in fails)
                {
                    Logger.Error("{0,-20}: {1}", fail.Key, fail.Value);
                }
            }
        }
        IEnumerator UploadVRCFile()
        {
            Debug.Log("Uploading VRC File...");
            SetUploadProgress("Uploading asset...", "Pushing those upload speeds!!", 0.1f);
            bool doneUploading = false;

            string filePath     = uploadVrcPath;
            string s3FolderName = "avatars";

            Uploader.UploadFile(filePath, s3FolderName, delegate(string obj) {
                string fileName    = s3FolderName + "/" + System.IO.Path.GetFileName(filePath);
                cloudFrontAssetUrl = "http://dbinj8iahsbec.cloudfront.net/" + fileName;
                doneUploading      = true;
            });

            while (!doneUploading)
            {
                yield return(null);
            }
        }
示例#13
0
        protected IEnumerator UploadVRCFile(string folderName)
        {
            Debug.Log("Uploading VRC File...");
            SetUploadProgress("Uploading asset...", "Pushing those upload speeds!!", 0.0f);
            bool doneUploading = false;

            string filePath = uploadVrcPath;
            var    s3       = Uploader.UploadFile(filePath, folderName, delegate(string obj) {
                string fileName    = folderName + "/" + System.IO.Path.GetFileName(filePath);
                cloudFrontAssetUrl = "http://dbinj8iahsbec.cloudfront.net/" + fileName;
                doneUploading      = true;
            });

            s3.StreamTransferProgress += OnUploadProgess;
            while (!doneUploading)
            {
                yield return(null);
            }
            s3.StreamTransferProgress -= OnUploadProgess;
        }
示例#14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //上传配置
            string pathbase = "upload/";                                                                    //保存路径
            int size = 2;           //文件大小限制,单位MB                                                                                                   //文件大小限制,单位MB
            string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };         //文件允许格式

            //上传图片
            Hashtable info = new Hashtable();
            Uploader up = new Uploader();
            info = up.upFile(context, pathbase, filetype, size);                               //获取上传状态

            string title = up.getOtherInfo(context, "pictitle");                              //获取图片描述

            string oriName = up.getOtherInfo(context, "fileName");                //获取原始文件名

            HttpContext.Current.Response.Write("{'url':'" + info["url"] + "','title':'" + title + "','original':'" + oriName + "','state':'" + info["state"] + "'}");  //向浏览器返回数据json数据
        }
        private void UploadButton_Click(object sender, EventArgs e)
        {
            String fileName = FiletextBox.Text;
            String urlstring= UrlTextBox.Text;
            progressBar.Value = 0;
            progressBar.Minimum = 0;
            progressBar.Maximum = 100;
            progressBar.Step = 1;
            if (fileName != "" && urlstring != "")
            {
                uploader = new Uploader(urlstring, fileName);

                statusDelegate st = new statusDelegate(setStatusMessage);
                cbProgress prog = new cbProgress(onProgress);

                uploader.startUpload(st,prog);

                //this.Close();
            }
        }
示例#16
0
 private async void Send(StorageFile file)
 {
     try
     {
         //viewModel.Dispatcher.Dispatch(async () =>
         //{
         //    await viewModel.SendVoiceNoteAsync(file, duration, null);
         //});
         //Transcode(file);
         try
         {
             await Helper.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 Uploader.UploadSingleVoice(file, CurrentThread.ThreadId);
             });
         }
         catch { }
     }
     catch { }
 }
示例#17
0
        public ActionResult Post()
        {
            var area    = new AreaRegistration();
            var allowed = FrapidConfig.GetAllowedUploadExtensions(this.Tenant);

            var uploader = new Uploader(Log.Logger, area, this.Request.Files, this.Tenant, allowed);

            try
            {
                string fileName = uploader.Upload();

                fileName = "/dashboard/config/services/attachments/" + fileName;

                return(this.Ok(fileName));
            }
            catch (UploadException ex)
            {
                return(this.Failed(ex.Message, HttpStatusCode.BadRequest));
            }
        }
示例#18
0
        public void SaveUpload()
        {
            int      boardId    = ctx.GetInt("boardId");
            HttpFile postedFile = ctx.GetFileSingle();

            Result result = Uploader.SaveFileOrImage(postedFile);

            if (result.HasErrors)
            {
                errors.Join(result);
                run(UploadForm);
                return;
            }

            AttachmentTemp uploadFile = savePostData(postedFile, result);

            // 返回数据给主页面
            set("objFile", SimpleJsonString.ConvertObject(uploadFile.GetJsonObject()));
            set("deleteLink", to(DeleteTempAttachment) + "?boardId=" + boardId);
        }
示例#19
0
 public async Task <bool> ReloadTexture(IStorageItem storageItem, Uploader uploader)
 {
     Mark(GraphicsObjectStatus.loading);
     if (!(storageItem is StorageFile texFile))
     {
         Mark(GraphicsObjectStatus.error);
         return(false);
     }
     try
     {
         uploader.Texture2D(await FileIO.ReadBufferAsync(texFile), true, true);
         Status = GraphicsObjectStatus.loaded;
         return(true);
     }
     catch
     {
         Mark(GraphicsObjectStatus.error);
         return(false);
     }
 }
        IEnumerator UploadUnityPackage()
        {
            Debug.Log("Uploading Unity Package...");
            SetUploadProgress("Uploading Unity Package...", "Future proofing your content!", 0.05f);
            bool doneUploading = false;

            string filePath     = uploadUnityPackagePath;
            string s3FolderName = "unitypackages";

            Uploader.UploadFile(filePath, s3FolderName, delegate(string obj) {
                string fileName           = s3FolderName + "/" + System.IO.Path.GetFileName(filePath);
                cloudFrontUnityPackageUrl = "http://dbinj8iahsbec.cloudfront.net/" + fileName;
                doneUploading             = true;
            });

            while (!doneUploading)
            {
                yield return(null);
            }
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Uploader uploader = new Uploader();
        if (fupOne.PostedFile.ContentLength > 0)
        {
            facility.ImageOne = uploader.UploadImage(fupOne.PostedFile,
                                            MapPath("~") + @"Images\Facilities\",
                                            720,
                                            false);
        }

        if (fupTwo.PostedFile.ContentLength > 0)
        {
            facility.ImageTwo = uploader.UploadImage(fupTwo.PostedFile,
                                            MapPath("~") + @"Images\Facilities\",
                                            720,
                                            false);
        }

        if (fupThree.PostedFile.ContentLength > 0)
        {
            facility.ImageThree = uploader.UploadImage(fupThree.PostedFile,
                                            MapPath("~") + @"Images\Facilities\",
                                            720,
                                            false);
        }

        if (fupFour.PostedFile.ContentLength > 0)
        {
            facility.ImageFour = uploader.UploadImage(fupFour.PostedFile,
                                            MapPath("~") + @"Images\Facilities\",
                                            720,
                                            false);
        }

        facility.Text = txbFacText.Text;
        facility.Address = txbAddress.Text;
        facilityFac.Update(facility);
        string currentURL = Request.RawUrl;
        Response.Redirect(currentURL);
    }
示例#22
0
        private void uploadButton_Click(object sender, RoutedEventArgs e)
        {
            // PhotoServiceSoapClient service = new PhotoServiceSoapClient();

            //check for selected gallery, if none selected prompt the user to select a gallery.
            if (galleryListBox.SelectedItem != null && uploadListBox.Items.Count > 0)
            {
                List <ClientImage> images = new List <ClientImage>();

                foreach (object image in uploadListBox.Items)
                {
                    ClientImage clientImage = (ClientImage)image;
                    images.Add(clientImage);
                }


                Uploader upload = new Uploader(images);
                upload.FileUploadComplete += new FileUploadCompletedEventHandler(upload_FileUploadComplete);
                upload.Upload();

                //CalculateProgressbar();

                //foreach (object image in uploadListBox.Items)
                //{
                //    ClientImage clientImage = (ClientImage)image;
                //    images.Add(clientImage);

                //    //string extension = Path.GetExtension(clientImage.ImageName);

                //    ////Upload the photos
                //    //service.Upload(Client.Default.token, clientImage.PhotoBytes, clientImage.GalleryId, extension);
                //    //UploadComplete();
                //}
            }
            else
            {
                //if there is no gallery selected then show the gallery error message
                //otherwise the problem must be no photos in the upload listbox
                uploadErrorMessage.Text = (galleryListBox.SelectedItem == null ? "Please select a gallery." : "Please choose a photo to upload.");
            }
        }
示例#23
0
        public void Upload_Empty_File_Returns_Success_Status()
        {
            var client        = new System.Net.Http.HttpClient();
            var profile       = "default";
            var roamingFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var logs          = Path.Combine(roamingFolder, "Porting Assistant for .NET", "logs");
            var teleConfig    = new TelemetryConfiguration
            {
                InvokeUrl       = "https://8q2itpfg51.execute-api.us-east-1.amazonaws.com/beta",
                Region          = "us-east-1",
                LogsPath        = logs,
                ServiceName     = "appmodernization-beta",
                Description     = "Test",
                LogFilePath     = Path.Combine(logs, "portingAssistant-client-cli-test.log"),
                MetricsFilePath = Path.Combine(logs, "portingAssistant-client-cli-test.metrics"),
            };

            var actualSuccessStatus = Uploader.Upload(teleConfig, client, profile, "");

            Assert.IsTrue(actualSuccessStatus);
        }
        IEnumerator UploadImage()
        {
            Debug.Log("Uploading Image...");

            bool doneUploading = false;

            SetUploadProgress("Uploading Image...", "That's a nice looking preview image ;)", 0.3f);
            string imagePath = imageCapture.TakePicture();

            Uploader.UploadFile(imagePath, "images", delegate(string imageUrl)
            {
                cloudFrontImageUrl = imageUrl;
                doneUploading      = true;
                VRC.Core.Logger.Log("Successfully uploaded image.", DebugLevel.All);
            });

            while (!doneUploading)
            {
                yield return(null);
            }
        }
示例#25
0
        private void button1_Click(object sender, EventArgs e)
        {
            UploaderSettings settings = new UploaderSettings
                                        (
                @"https://shailes.herokuapp.com/boriscam/upload",
                10,
                0,
                24
                                        );


            Uploader = new WebCamUploader.Uploader
                       (
                settings,
                WebCamUploader_FileUploaded,
                WebCamUploader_Error
                       );
            stopButton.Enabled  = true;
            startButton.Enabled = false;
            Uploader.start();
        }
示例#26
0
        public void SavePic()
        {
            if (ctx.HasUploadFiles == false)
            {
                echoRedirect("不能上传空图片", Index);
                return;
            }

            HttpFile file      = ctx.GetFileSingle();
            Result   result    = Uploader.SaveImg(file);
            string   savedPath = result.Info.ToString();

            UploadFile f = new UploadFile();

            f.Name     = file.FileName;
            f.Path     = savedPath;
            f.FileType = (int)FileType.Pic;
            f.insert();

            redirect(Index);
        }
示例#27
0
        static void testSampleSingleFile()
        {
            string fname = "s.txt";
            string ip    = "127.0.0.1";

            RepositoryLib.Config.Initialize(ip, _repositoryRootFolder);

            if (!Uploader.Upload(_sourceRootPath + fname))
            {
                Console.WriteLine("[ERROR], Uploader.Upload fail");
                return;
            }
            Console.WriteLine("[DEBUG], Uploader.Upload success");

            if (!Downloader.Download(_downloadRootPath, fname))
            {
                Console.WriteLine("[ERROR], Downloader.Download fail");
                return;
            }
            Console.WriteLine("[DEBUG], Downloader.Download success");
        }
示例#28
0
        public ActionResult GlemtAdgangskode(string email)
        {
            if (bf.UserExist(email))
            {
                Uploader uploader      = new Uploader();
                string   nyAdgangskode = uploader.GenRnd(8);

                bf.UpdateAdgangskode(email, Crypto.Hash(nyAdgangskode));

                MailFac mf = new MailFac("smtp.gmail.com", "*****@*****.**", "*****@*****.**", "Fedeaba2000", 587);

                mf.Send("Ny adgangskode", nyAdgangskode, email);

                ViewBag.MSG = "Du vil om lidt modtage en email med en ny adgangskode!";
            }
            else
            {
                ViewBag.MSG = "Brugeren findes ikke i databasen";
            }
            return(View());
        }
示例#29
0
        public async Task <IActionResult> ChangeImage(IFormFile image)
        {
            if (image != null)
            {
                var root = _env.WebRootPath;
                var user = await _userManager.GetUserAsync(HttpContext.User);

                var imagePath = Uploader.UploadProfileImage(image, root);
                user.ProfileImg = imagePath;
                _unitOfWork.Donor.SaveProfileImage(user);
                _unitOfWork.Save();
                return(Redirect("Index"));
            }
            else
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                ViewBag.SelectImage = "Please select image!";
                return(View("~/Views/MyProfile/ChangeImage.cshtml", user));
            }
        }
示例#30
0
        public void LogoSave()
        {
            Result result = Uploader.SaveSiteLogo(ctx.GetFileSingle());

            if (result.IsValid)
            {
                String logoThumb = result.Info.ToString();
                String logo      = wojilu.Drawing.Img.GetOriginalPath(logoThumb);


                config.Instance.Site.SiteLogo = logo;
                config.Instance.Site.Update("SiteLogo", logo);
                log(SiteLogString.UpdateLogo());
                redirect(Logo);
            }
            else
            {
                errors.Join(result);
                run(Logo);
            }
        }
示例#31
0
        public OperationResult Delete(long id)
        {
            OperationResult result = new OperationResult();

            var article = _articleRepository.Get(id);

            if (article == null)
            {
                return(result.Failed(ValidateMessage.IsExist));
            }

            var slug         = article.Slug;
            var categorySlug = _categoryRepository.GetCategorySlugBy(article.CategoryId);
            var folderName   = $"{categorySlug}\\{slug}";

            article.Delete();
            Uploader.DirectoryRemover(folderName);

            _articleRepository.SaveChanges();
            return(result.Succeeded());
        }
示例#32
0
        private void makeThumbPrivate(String photoPath)
        {
            // 循环生成所有缩略图
            foreach (KeyValuePair <String, ThumbInfo> kv in ThumbConfig.GetPhotoConfig())
            {
                String srcPath = getPhotoSrcPath(photoPath);
                if (file.Exists(srcPath) == false)
                {
                    logError("pic original not exist=" + srcPath);
                    continue;
                }

                log("begin make " + kv.Key + "=>" + srcPath);
                try {
                    Uploader.SaveThumbSingle(srcPath, kv.Key, kv.Value);
                }
                catch (Exception ex) {
                    logError("error=>" + ex.Message);
                }
            }
        }
示例#33
0
        public HttpResponseMessage UploadAvatar()
        {
            return(this.ExecuteOperationAndHandleExceptions(() =>
            {
                var httpRequest = HttpContext.Current.Request;

                var context = new GameContext();
                var dbUser = UserPersister.GetUserByUsernameAndDisplayName(httpRequest.Form["username"], httpRequest.Form["nickname"], context);
                if (dbUser == null)
                {
                    throw new InvalidOperationException("This user already exists in the database");
                }


                if (httpRequest.Files.Count > 0)
                {
                    foreach (string file in httpRequest.Files)
                    {
                        var postedFile = httpRequest.Files[file];

                        var configuration = new AccountConfiguration("djlwcsyiz", "781383948985498", "Vh5BQmeTxvSKvTGTg-wRDYKqPz4");

                        var uploader = new Uploader(configuration);
                        string publicId = Path.GetFileNameWithoutExtension(postedFile.FileName);
                        var uploadResult = uploader.Upload(new UploadInformation(postedFile.FileName, postedFile.InputStream)
                        {
                            PublicId = publicId,
                            Format = postedFile.FileName.Substring(postedFile.FileName.Length - 3),
                        });

                        dbUser.Avatar = uploadResult.Url;
                    }
                }

                context.SaveChanges();

                var response = this.Request.CreateResponse(HttpStatusCode.NoContent);
                return response;
            }));
        }
示例#34
0
        public void SaveBoard()
        {
            ForumBoard fb = ForumValidator.ValidateBoard(ctx);

            if (errors.HasErrors)
            {
                run(AddSubBoard, fb.Id);
                return;
            }

            Result result = boardService.Insert(fb);

            if (result.HasErrors)
            {
                errors.Join(result);
                run(AddSubBoard, fb.Id);
                return;
            }

            String str = ((ForumApp)ctx.app.obj).Security;

            boardService.UpdateSecurity(fb, str);

            // 上传图片处理
            if (ctx.HasUploadFiles)
            {
                HttpFile uploadFile = ctx.GetFileSingle();
                if (uploadFile.ContentLength > 1)
                {
                    Result uploadResult = Uploader.SaveImg(uploadFile);
                    if (uploadResult.IsValid)
                    {
                        boardService.UpdateLogo(fb, uploadResult.Info.ToString());
                    }
                }
            }

            logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("addBoard") + ":" + fb.Name, ctx.Ip);
            echoToParentPart(lang("opok"));
        }
示例#35
0
        public void addMagazine(MagazineModel mm)
        {
            string imgfile  = string.Empty;
            var    img      = new Uploader("Image", new string[] { ".jpg", ".png", ".gif", ".jpeg" });
            string delpath1 = "E:/boiler/gygl/gygl2016/Content/Upload/Magazine/Cover/";
            string delpath2 = "/Content/upload/magazine/cover/";

            if (img.checkUpload())
            {
                img.save(delpath1, new Cut {
                    width = 190, height = 255, mode = "Cut"
                }, false);
                img.save(delpath2, new Cut {
                    width = 80, height = 80, mode = "Cut"
                });
                //这边还可以继续保存
                img.end();
                imgfile = img.FileName;
            }

            var a = new Gygl
            {
                Name        = mm.Name,
                Year        = int.Parse(mm.Year),
                Period      = int.Parse(mm.Period),
                TotalPeriod = int.Parse(mm.TotalPeriod),
                Publish     = Convert.ToDateTime(mm.Publish),
                CoverImage  = imgfile
            };

            this.gygl.Insert(a);
            foreach (var item in mm.Category)
            {
                this.gyglCategoryRelation.Insert(new GyglCategoryRelation
                {
                    GyglID     = a.ID,
                    CategoryID = int.Parse(item)
                });
            }
        }
示例#36
0
        public async Task Upload_BooksUpToDate_NoCalls()
        {
            var fileSource = Substitute.For <ISimpleDataSource>();
            var bookSource = Substitute.For <IFullDataSource>();
            var messages   = Substitute.For <IOutputMessage>();
            var uploader   = new Uploader(bookSource, fileSource, messages);

            MatchInfo[] books = new MatchInfo []
            {
                new MatchInfo(MakeBook(null, "Titlt", "Author", "MOBI"))
                {
                    IsSelected = true,
                    Status     = MatchStatus.UpToDate
                }
            };

            await uploader.Upload(books);

            ICall[] calls = bookSource.ReceivedCalls().ToArray();

            Assert.AreEqual(0, calls.Length);
        }
        /// <summary>
        /// Checks that the backend hash matches the reality and
        /// if so, registers the build. Else prints warning.
        /// </summary>
        private static void TryToRegisterTheBuild(BuildReport report)
        {
            // check that the backendHash in preferences is up to date
            bool uploadNeeded = Uploader.GetDefaultInstance()
                                .RecalculateBackendHash();

            if (uploadNeeded)
            {
                Debug.LogWarning(
                    "[Unisave] This backend has not yet been uploaded, " +
                    "therefore build registration is being skipped. " +
                    "Enable automatic backend upload or upload the backend " +
                    "manually before you build your game to resolve this issue."
                    );
                return;
            }

            // register the build
            BuildRegistrator
            .GetDefaultInstance()
            .RegisterBuild(report);
        }
示例#38
0
        public void Cancel(bool cancelYoutubeUploader)
        {
            LOGGER.Debug($"Received cancel request");

            if (State == RunningState.Running)
            {
                LOGGER.Info($"Cancelling auto uploader");

                State = RunningState.CancelPending;
                Uploader.StopAfterCompleting = true;
                Searcher.Cancel();
                DirectoryWatcher.Cancel();

                if (cancelYoutubeUploader)
                {
                    LOGGER.Info($"Cancelling youtube uploader");
                    Uploader.CancelAll();
                }

                RefreshState();
            }
        }
        public ActionResult AddProd(HttpPostedFile file)
        {
            var u = new Uploader();
            var p = new Produkt();
            string path = Request.PhysicalApplicationPath + "images/";
            p.KatID = int.Parse(Request["ddlKat"]);

            for (var i = 0; i < Request.Files.Count; i++)
            {
                var postedFile = Request.Files[i];
                p.Billede = Path.GetFileName(u.UploadImage(postedFile, path, 0, true));

            }

            p.Navn = Request["txtNavn"];
            p.Pris = decimal.Parse(Request["txtPris"]);
            p.Tekst = Request["txtTekst"];

            pf.Insert(p);

            return View("AddProduct");
        }
示例#40
0
        public async Task <IActionResult> Edit(ForumCreateModel model)
        {
            if (model.ImageUpload != null)
            {
                Uri uri = await Uploader.UploadImage("forum-images", model.ImageUpload, _configuration, _uploadService);

                model.ForumImageUrl = uri.AbsoluteUri;
            }

            if (ModelState.IsValid)
            {
                await _forumService.UpdateForumDescription(model.Id, model.Description);

                await _forumService.UpdateForumImageUrl(model.Id, model.ForumImageUrl);

                await _forumService.UpdateForumTitle(model.Id, model.Title);

                return(RedirectToAction("Index", "Forum"));
            }

            return(View(model));
        }
示例#41
0
        public ActionResult AddPosition(DiveRepo.DiveTracker dive, HttpPostedFileBase billeder)
        {
            dive.Billeder = null;


            if (billeder != null)
            {
                Uploader uploader = new Uploader();
                string   path     = Request.PhysicalApplicationPath + "/Content/";

                string fil = uploader.UploadImage(billeder, path, 255, true);

                dive.Billeder = System.IO.Path.GetFileName(fil);
            }
            else
            {
                ViewBag.MSG = "Der er Ikke valgt et billede";
            }

            Df.Insert(dive);
            return(RedirectToAction("AddPosition"));
        }
示例#42
0
        // flash上传(逐个保存)
        public void SaveUpload()
        {
            int albumId          = ctx.PostInt("PhotoAlbumId");
            int systemCategoryId = ctx.PostInt("SystemCategoryId");

            if (ctx.HasUploadFiles == false)
            {
                echoText(lang("exPlsUpload"));
                return;
            }

            HttpFile file = ctx.GetFileSingle();

            logger.Info(file.FileName + "=>" + file.ContentType);

            Result result = Uploader.SaveImg(file);

            if (result.HasErrors)
            {
                errors.Join(result);
                echoError(result);
            }
            else
            {
                PhotoPost post = newPost(Path.GetFileNameWithoutExtension(file.FileName), result.Info.ToString(), albumId, systemCategoryId);
                PhotoApp  app  = ctx.app.obj as PhotoApp;
                postService.CreatePost(post, app);

                // 统计
                User user = ctx.owner.obj as User;
                user.Pins = PhotoPost.count("OwnerId=" + user.Id);
                user.update("Pins");

                Dictionary <String, int> dic = new Dictionary <String, int>();
                dic.Add("Id", post.Id);

                echoJsonMsg("ok", true, dic);
            }
        }
示例#43
0
        private void uploadToCloud(string filename, Stream fileStream)
        {
            if (filename.EndsWith("png") || filename.EndsWith("jpeg") || 
                filename.EndsWith("jpg") || filename.EndsWith("gif") || filename.EndsWith("bmp"))
            {
                try
                {
                    var configuration = new AccountConfiguration("hscl3sr21", "773858917884263", "RWVBnZhCDPyOrKAYihbubppmZ4E");

                    var uploader = new Uploader(configuration);
                    string publicId = Path.GetFileNameWithoutExtension(filename);
                    var uploadResult = uploader.Upload(new UploadInformation(filename, fileStream)
                    {
                        PublicId = publicId,
                        Format = filename.Substring(filename.Length - 3),
                    });
                }
                catch (Exception ex)
                {
                    //context.Response.Write("{ 'success': " + ex.Message + " }");
                    return;
                }
            }
        }
        public MainPageViewModel(Dispatcher dispatcher)
        {
            this.audioRecorder = new AudioRecorder(dispatcher);
            this.audioRecorder.RecorderStopped += new EventHandler(RecorderStopped);
            this.audioRecorder.RecorderStarted += new EventHandler(RecorderStarted);
            this.pictureTaker = new PictureTaker();
            this.pictureTaker.TakePictureCompleted +=
                new EventHandler<CaptureImageCompletedEventArgs>(TakePictureCompleted);

            this.serverMonitor = new ServerMonitor(this.ServerMediaItems);
            this.serverMonitor.DownloadComplete += ((s, args) =>
            {
                if (!App.Current.IsRunningOutOfBrowser)
                {
                    var items = from i in this.ServerMediaItems
                                where i.IsAudio == false
                                orderby i.Name descending
                                select i;
                    var item = items.FirstOrDefault();
                    if (item != null)
                    {
                        HtmlPage.Window.Invoke("lastImageUploaded", item.Url);
                    }
                }

            });

            this.uploader = new Uploader(dispatcher, this.LocalMediaItems);
            this.uploader.QueueEmptied += ((s, args) =>
            {
                this.serverMonitor.Download();
            });

            this.serverMonitor.Download();
            this.AllowedDeviceAccess = CaptureDeviceConfiguration.AllowedDeviceAccess;
        }
示例#45
0
        public ActionResult GalleriRedigere(List<HttpPostedFileBase> file)
        {
            Uploader uploader = new Uploader();
            GkkGalleri RedigereGalleri = new GkkGalleri();
            GkkGalleriFac RedigereGalleriFac = new GkkGalleriFac();

            foreach (HttpPostedFileBase fil in file)
            {
                if (fil.ContentLength > 0 && file != null)
            {
                    string appPath = Request.PhysicalApplicationPath;
                    RedigereGalleri.BilledeStor = uploader.UploadImage(fil, appPath + @"Content\Images\", 0, true);
                    RedigereGalleri.BilledeLille = uploader.UploadImage(fil, appPath + @"Content\Images\", 200, true);

                RedigereGalleriFac.Insert(RedigereGalleri);
            }
            }

            return RedirectToAction("GalleriRedigere");
        }
        private void uploadToCloud(string filename, string uploadFileName, Stream fileStream, Message msg, Channel chan, string file)
        {
            if (filename.EndsWith("png") || filename.EndsWith("jpeg") || filename.EndsWith("jpg") || filename.EndsWith("gif") || filename.EndsWith("bmp"))
            {
                try
                {
                    msg.Type = MessageTypes.Image;
                    var configuration = new AccountConfiguration("saykor", "277334748579534", "mUjzZ-X3jOuNKGswrAjocB-D-Rc");

                    var uploader = new Uploader(configuration);
                    string publicId = Path.GetFileNameWithoutExtension(filename);
                    var uploadResult = uploader.Upload(new UploadInformation(filename, fileStream)
                    {
                        PublicId = publicId,
                        Format = filename.Substring(filename.Length - 3),
                    });
                    //msg.Content = uploadResult.Url;
                    msg.Content = filename;
                }
                catch (Exception ex)
                {
                    //context.Response.Write("{ 'success': " + ex.Message + " }");
                    return;
                }
            }
            else
            {
                //upload to dropbox
                string cloudPath = "/" + chan.Name + "/" + filename;
                _sessionState.AuthClient();
                var result = _sessionState.DropboxClient.UploadFileAsync(new FileResource(file), cloudPath).Result;
                msg.Content = cloudPath;
            }
        }
 public UploadWizard()
 {
     InitializeComponent();
     _uploader = new Uploader();
     StartStep1();
 }
示例#48
0
        public ActionResult ForsideRedigerBestyrelsen(GkkBestyrelsen RedigereBestyrelsen, HttpPostedFileBase file)
        {
            Uploader uploader = new Uploader();

            if (file.ContentLength > 0 && file != null)
            {
                string appPath = Request.PhysicalApplicationPath;
                RedigereBestyrelsen.Billede = uploader.UploadImage(file, appPath + @"Content\Images\", 250, true);
            }

            GkkBestyrelsenFac bestyrelsenFac = new GkkBestyrelsenFac();
            bestyrelsenFac.Insert(RedigereBestyrelsen);

            //GkkRedigerFac RedigerSide = new GkkRedigerFac();

            return RedirectToAction("ForsideRediger");
        }
示例#49
0
		void client_FinishUploadCompleted(object sender, Uploader.Client.FileReceiver.FinishUploadCompletedEventArgs e)
		{
			if (!e.Cancelled && e.Error == null)
			{
				if (e.Result.Status == Uploader.Client.FileReceiver.EnumsResponsStatus.Success)
				{
					uxText.Text = "Transferred successfully.";
				}
				else
					uxText.Text = e.Result.Message;
			}
			else
			{
				if (e.Error != null)
					uxText.Text = e.Error.Message;
				else
					uxText.Text = "Cancelled";
			}
		}
        private void uploadToCloud(string filename, string uploadFileName, HttpContext context, Message msg, Channel chan, string file)
        {
            if (filename.EndsWith("png") || filename.EndsWith("jpeg") || filename.EndsWith("jpg") || filename.EndsWith("gif") || filename.EndsWith("bmp"))
            {
                try
                {
                    msg.PublicData.Type = MessageTypes.Image;
                    var configuration = new AccountConfiguration("saykor", "277334748579534", "mUjzZ-X3jOuNKGswrAjocB-D-Rc");

                    var uploader = new Uploader(configuration);
                    string publicId = Path.GetFileNameWithoutExtension(filename);
                    Stream stream;
                    if (string.IsNullOrEmpty(uploadFileName) == true) // IE Browsers
                        stream = context.Request.Files[0].InputStream;
                    else // Other Browsers
                        stream = context.Request.InputStream;

                    var uploadResult = uploader.Upload(new UploadInformation(filename, stream)
                    {
                        PublicId = publicId,
                        Format = filename.Substring(filename.Length - 3),
                    });
                    msg.PublicData.Value = filename;
                }
                catch (Exception ex)
                {
                    context.Response.Write("{ 'success': " + ex.Message + " }");
                    return;
                }
            }
            else
            {
                //upload to dropbox
                string cloudPath = "/" + chan.Name + "/" + filename;
                _sessionState.AuthClient();
                var result = _sessionState.Client.UploadFileAsync(new FileResource(file), cloudPath).Result;
                msg.PublicData.Value = cloudPath;
            }
        }
示例#51
0
 private void PrepareUploader(Uploader currentUploader)
 {
     uploader = currentUploader;
     uploader.BufferSize = (int)Math.Pow(2, App.Settings.BufferSizePower) * 1024;
     uploader.ProgressChanged += uploader_ProgressChanged;
 }
示例#52
0
 private string UploadToCloudinary(HttpPostedFileBase file, string filename)
 {
     var settings = ConfigurationManager.AppSettings;
     var configuration = new AccountConfiguration(settings["Cloudinary.CloudName"],
                                                  settings["Cloudinary.ApiKey"],
                                                  settings["Cloudinary.ApiSecret"]);
     var uploader = new Uploader(configuration);
     string publicId = Path.GetFileNameWithoutExtension(filename);
     // Upload the file
     var destroyResult = uploader.Destroy(publicId);
     var uploadResult = uploader.Upload(new UploadInformation(filename, file.InputStream)
                         {
                             // explicitly specify a public id (optional)
                             PublicId = publicId,
                             // set the format, (default is jpg)
                             Format = "png",
                             // Specify some eager transformations
                             Eager = new[]
                             {
                                 new Transformation(100, 100) { Format = "png", Crop = CropMode.Thumb, Gravity = Gravity.Face, Radius = 8 }, //, Angle = new Angle(90)
                             }
                         });
     return uploadResult.Version;
 }
示例#53
0
文件: VForm.cs 项目: windrobin/kumpro
        private void UploadThem(String[] alfp, Uri baseUri) {
            BackgroundWorker bwIO = new BackgroundWorker();

            ManualResetEvent cancel = new ManualResetEvent(false);
            using (NowUpForm form = new NowUpForm(bwIO, cancel)) {
                Uploader io = new Uploader(conn, this, form, cancel);
                bwIO.DoWork += delegate(object sender, DoWorkEventArgs e) {
                    io.UploadThem(alfp, baseUri);
                };

                form.ShowDialog(this);
            }
        }
示例#54
0
 public MainViewModel()
 {
     _uploader = new Uploader();
     _uploaderView = new UploaderControlView { DataContext = this };
 }
示例#55
0
 //
 // Initialization
 //
 public TabbloExport()
 {
     model = new TabbloExportModel ();
     uploader = new Uploader (model);
 }
示例#56
0
		void client_BeginUploadCompleted(object sender, Uploader.Client.FileReceiver.BeginUploadCompletedEventArgs e)
		{
			if (!e.Cancelled && e.Error == null)
			{
				if (e.Result.Status == Uploader.Client.FileReceiver.EnumsResponsStatus.Success)
				{
					UpdateProgress();

					if (this.FilePosition < this.FileLength)
						SendNextChunk(e.Result.Token);
					else
					{
						//finish upload. 
						FinishUpload(e.Result.Token);
					}
				}
				else
					uxText.Text = e.Result.Message;
			}
			else if (e.Error != null)
			{
				this.uxText.Text = e.Error.Message;
			}
			else
			{
				this.uxText.Text = "Cancelled";
			}
		}
示例#57
0
 public void TestInit() {
     _uploader = new Uploader();
 }
示例#58
0
        /// <summary>
        /// Opens the file to be read. 
        /// </summary>
        /// <param name="filePath"></param>
        private void OpenFile(string filePath, string USGSID)
        {
            try
            {
                ApplicationLog.WriteMessageToLog("Opening File: " + filePath, false, false, false);

                // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader(filePath))
                {
                    // Read the stream to a string, and write the string to the console
                    var data = ExtractData(sr, filePath);
                    Uploader rtiUploader = new Uploader();
                    if(data.Count() > 0) // Only upload if there is data to be uploaded.
                        rtiUploader.Upload(data, USGSID);
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteMessageToLog("Error: " + ex.Message + " Inner" + ex.InnerException, true, true, true);
                System.Diagnostics.Debugger.Break();
                UserInterface.WriteToConsole("There was an error reading this file: ");
                UserInterface.WriteToConsole(ex.Message);
            }
        }
        public void StartProcess()
        {
            if (Model.RecordingInfo == null) return;

            TodoListItem tiCombineAudio = Model.TodoList[0];
            TodoListItem tiEncodeWebm = Model.TodoList[1];
            TodoListItem tiConvertGif = Model.TodoList[2];
            TodoListItem tiUpload = Model.TodoList[3];

            worker = new BackgroundWorker {WorkerSupportsCancellation = true};
            worker.DoWork += (ws, we) =>
            {
                double progressLimitForEachTodo = 100.0 / Model.TodoList.Count;
                converter = new Converter(Model.RecordingInfo.Path);
                converter.Progress += (s, e) =>
                {
                    double currentTodoProgressPercent = Model.CurrentProgress - (((int) (Model.CurrentProgress / progressLimitForEachTodo)) * progressLimitForEachTodo);
                    Model.CurrentProgress += ((progressLimitForEachTodo / 100 * e.DonePercentage) - currentTodoProgressPercent) * (progressLimitForEachTodo / 100);
                };

                // combine audio and video
                tiCombineAudio.State = TodoListItemState.Processing;
                converter.Combine();
                tiCombineAudio.State = TodoListItemState.Finished;
                Model.CurrentProgress = progressLimitForEachTodo;

                // convert to webm
                tiEncodeWebm.State = TodoListItemState.Processing;
                converter.ToWebm();
                if (converter.FinishedGood)
                {
                    tiEncodeWebm.State = TodoListItemState.Finished;
                    tiEncodeWebm.Text = tiEncodeWebm.Text + " (" + Model.RecordingInfo.Path + ".webm)";
                    Model.RecordingInfo.Formats.Add("webm");
                }
                else
                {
                    tiEncodeWebm.State = TodoListItemState.Failed;
                }
                Model.CurrentProgress = progressLimitForEachTodo * 2;

                // generate gif
                tiConvertGif.State = TodoListItemState.Processing;
                if (Model.RecordingInfo.Duration <= 30)
                {
                    converter.ToGif();
                    if (converter.FinishedGood)
                    {
                        tiConvertGif.State = TodoListItemState.Finished;
                        tiConvertGif.Text = tiConvertGif.Text + " (" + Model.RecordingInfo.Path + ".gif)";
                        Model.RecordingInfo.Formats.Add("gif");
                    }
                    else
                    {
                        tiConvertGif.State = TodoListItemState.Failed;
                    }
                }
                else
                {
                    tiConvertGif.Text = tiConvertGif.Text + " (skipped. limit 30 second)";
                    tiConvertGif.State = TodoListItemState.Failed;
                }
                Model.CurrentProgress = progressLimitForEachTodo * 3;

                // upload
                tiUpload.State = TodoListItemState.Processing;
                try
                {
                    uploader = new Uploader(Model.RecordingInfo);
                    uploader.Progress += (s, e) =>
                    {
                        Model.CurrentProgress += (progressLimitForEachTodo / 100 * e.UploadedPercentage) -
                                                 Model.CurrentProgress + (progressLimitForEachTodo * 2);
                    };
                    uploader.StartSync();
                    tiUpload.State = TodoListItemState.Finished;
                    JObject uploaderResponse = uploader.JsonResponse;
                    Model.RecordingInfo.Url = uploaderResponse["url"].ToString();
                    Model.RecordingInfo.ActionKey = uploaderResponse["actionKey"].ToString();
                }
                catch (Exception e)
                {
                    tiUpload.State = TodoListItemState.Failed;
                    tiUpload.Text = tiUpload.Text + " " + e.Message;
                    Model.ProgressState = ProgressState.Failed;
                }
                Model.CurrentProgress = 100;
            };

            worker.RunWorkerCompleted += (s, e) =>
            {
                string headerText = "Generated: MP4";
                if (tiEncodeWebm.State == TodoListItemState.Finished)
                {
                    headerText += ", WEBM";
                }
                if (tiConvertGif.State == TodoListItemState.Finished)
                {
                    headerText += ", GIF";
                }
                if (tiUpload.State == TodoListItemState.Failed)
                {
                    headerText = " Upload failed.";
                    Model.RecordingInfo.Url = "Not uploaded";
                }
                else
                {
                    var link = new Hyperlink {NavigateUri = new Uri(Model.RecordingInfo.Url)};
                    link.Inlines.Add(Model.RecordingInfo.Url);
                    headerText = " Uploaded: " + link;
                }
                Model.Header = headerText;
                new RecManagerService().AddRecording(Model.RecordingInfo);
            };

            worker.RunWorkerAsync();
        }
示例#60
0
        public HttpResponseMessage UploadAvatar()
        {
            return this.ExecuteOperationAndHandleExceptions(() =>
            {
                var httpRequest = HttpContext.Current.Request;

                var context = new GameContext();
                var dbUser = UserPersister.GetUserByUsernameAndDisplayName(httpRequest.Form["username"], httpRequest.Form["nickname"], context);
                if (dbUser == null)
                {
                    throw new InvalidOperationException("This user already exists in the database");
                }

                if (httpRequest.Files.Count > 0)
                {
                    foreach (string file in httpRequest.Files)
                    {
                        var postedFile = httpRequest.Files[file];

                        var configuration = new AccountConfiguration("djlwcsyiz", "781383948985498", "Vh5BQmeTxvSKvTGTg-wRDYKqPz4");

                        var uploader = new Uploader(configuration);
                        string publicId = Path.GetFileNameWithoutExtension(postedFile.FileName);
                        var uploadResult = uploader.Upload(new UploadInformation(postedFile.FileName, postedFile.InputStream)
                        {
                            PublicId = publicId,
                            Format = postedFile.FileName.Substring(postedFile.FileName.Length - 3),
                        });

                        dbUser.Avatar = uploadResult.Url;
                    }
                }

                context.SaveChanges();

                var response = this.Request.CreateResponse(HttpStatusCode.NoContent);
                return response;
            });
        }