Exemplo n.º 1
0
 public static void Create(Photo photo)
 {
     using (var db = Db())
     {
         db.Execute(@"
             INSERT INTO [Photos]
                 ([user],   description,  photourl, created)
             values
                 (@user, @description, @photourl, GETUTCDATE())
         ", photo);
     }
 }
Exemplo n.º 2
0
        public ActionResult Create(Photo photo)
        {
            var photoFile = Request.Files["photo-file"];

            photo.User = Session["user"] as string;
            photo.PhotoUrl = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(photoFile.FileName);

            using (var s3 = new AmazonS3Client())
            {
                s3.PutObject(new Amazon.S3.Model.PutObjectRequest
                {
                    CannedACL = Amazon.S3.Model.S3CannedACL.PublicRead,
                    BucketName = "betamore-photoup",
                    InputStream = photoFile.InputStream,
                    Key = photo.PhotoUrl
                });
            }

            Photo.Create(photo);

            return RedirectToAction("Index");
        }