Esempio n. 1
0
        public async Task <Uri> UploadProfilePicture([FromForm] ProfilePictureUpload upload)
        {
            if (upload.Photo == null)
            {
                throw new ArgumentNullException("file");
            }
            if (upload.Photo.Length > maxProfilePictureSizeInBytes)
            {
                throw new ArgumentException($"File is too large. Please upload files smaller than {maxProfilePictureSizeInBytes}")
                      .WithData("size", upload.Photo.Length);
            }

            var user = await GetUserOrThrow();

            //delete the old image
            if (user.ProfilePicUrl != null)
            {
                await cdnManager.DeleteProfilePicAsync(user);
            }

            using (var fileStream = upload.Photo.OpenReadStream())
            {
                user.ProfilePicUrl = await cdnManager.UploadProfilePicAsync(fileStream, upload.Photo.ContentType ?? "image/jpg");
            }

            return(user.ProfilePicUrl);
        }
Esempio n. 2
0
 public void signup(object sender, EventArgs e)
 {
     try
     {
         BLL.User u = new User(Username.Text, UserType.User, email.Text, Calendar.SelectedDate, FName.Text, LName.Text, Password.Text);
         Session["User"] = u;
         ProfilePictureUpload.UploadPhoto();
         Response.Redirect(@"~\Home.aspx");
     }
     catch (Exception ex)
     {
         error.Text = "couldn't sign up, " + ex.Message;
     }
 }
Esempio n. 3
0
 protected void UploadPicBtn_Click(object sender, EventArgs e)
 {
     ProfilePictureUpload.UploadPhoto();
 }