Esempio n. 1
0
        public static string UploadPhoto(CoverPhoto CurrentPhoto)
        {
            try
            { 
                var client = GetAmazonCleint();
                String S3_KEY ="CoverPhotos/"+ CurrentPhoto.UserEmail+".jpg"
                    ;

                PutObjectRequest request = new PutObjectRequest();
                request.BucketName = BUCKET_NAME;
                request.Key = S3_KEY;
                request.ContentBody = @"    ftypisom   isomiso2avc1mp41 ÅHmoov   lmvhd              è h                                            @                                ";
                request.CannedACL = S3CannedACL.PublicRead;

                client.PutObject(request);
                var Url = GetItemPublicUrlForVideo(S3_KEY);
                return Url;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Esempio n. 2
0
        public static CoverPhoto SaveNewPhoto(int UserID,string UserEmail)
        {
            try
            {


                CoverPhoto NewPhoto = new CoverPhoto();

                using (var context = new PostContext())
                {
                    // save New Video block .......

                    NewPhoto.UserID = UserID;
                    NewPhoto.UserEmail = UserEmail;
                    NewPhoto.PhotoPath = UploadPhoto(NewPhoto);
                    context.Photos.Add(NewPhoto);
                    context.SaveChanges();
                }
                return NewPhoto;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }