Beispiel #1
0
        public void CanSaveAndGetInfoPNG_UserSetDateAndDuration_UserDateHonoured_DurationHonoured()
        {
            // Arrange
            var form = new UploadForm(_inviteToOverrideAutoValues);

            form.SetDisplayDuration("100", 5, 200);
            form.SetDateIfNotEmpty("2011-12-20");

            using (var ms = new MemoryStream())
            {
                TestFiles.SamplePNG.Save(ms, ImageFormat.Png);

                UploadedFile file = new UploadedImageFile(form, _durationDetectorFactory);
                file.RawContentPath            = _rawContentPath;
                file.ThumbnailAssetContentPath = _thumbnailAssetContentPath;
                file.UploadedStream            = ms;

                // Act
                file.OriginalFileName = "Sample_PNG.png";
                file.SetDateIfUserHasNotProvidedOne("2011 7 8");

                SaveThumbnail(file);

                // Assert
                Assert.AreEqual("Sample_PNG", file.Title);
                Assert.AreEqual(".png", file.Extension);
                Assert.AreEqual(new DateTime(2011, 12, 20), file.Date);
                Assert.AreEqual(PreviewType.Image, file.PreviewType);
                Assert.AreEqual(100, file.DisplayDuration);
            }
        }
Beispiel #2
0
        public void CanSaveAndGetInfoJPG_NoUserData()
        {
            // Arrange
            var form = new UploadForm(_inviteToOverrideAutoValues);

            // Act
            using (var ms = new MemoryStream())
            {
                TestFiles.sampleJPG.Save(ms, ImageFormat.Jpeg);

                UploadedFile file = new UploadedImageFile(form, _durationDetectorFactory);
                file.RawContentPath            = _rawContentPath;
                file.ThumbnailAssetContentPath = _thumbnailAssetContentPath;
                file.UploadedStream            = ms;

                // Act
                file.OriginalFileName = "Sample_JPG.jpg";
                file.SetDateIfUserHasNotProvidedOne("2011 7 8");

                SaveThumbnail(file);

                // Assert
                Assert.AreEqual("Sample_JPG", file.Title);
                Assert.AreEqual(".jpg", file.Extension);
                Assert.AreEqual(new DateTime(2011, 7, 8), file.Date);
                Assert.AreEqual(1184183, file.ContentLength);
                Assert.AreEqual(PreviewType.Image, file.PreviewType);
                Assert.AreEqual(-1, file.DisplayDuration);
            }
        }
Beispiel #3
0
    protected void Upload(object sender, EventArgs e)
    {
        string filename = UniqueFilename(UploadedImageFile.FileName);

        UploadedImageFile.SaveAs(FileLinkFolder + filename);

        BindImageList();
        ImageList.SelectedValue = filename;
        SelectImage(null, null);
    }
Beispiel #4
0
        public async Task OnPostUploadAsync()
        {
            if (IsImage(UploadedImageFile.FileName))
            {
                string filename = UniqueFilename(UploadedImageFile.FileName);
                var    stream   = new MemoryStream();
                UploadedImageFile.CopyTo(stream);
                byte[] image = await ResizeImageBytes(stream.ToArray(), 1024, 1024); //make 1024x1024 the largest image size

                System.IO.File.WriteAllBytes(FileImageFolder + filename, image);

                ImageListValue = filename;
                await OnPostSelectImageAsync();
            }
        }
Beispiel #5
0
    protected void Upload(object sender, EventArgs e)
    {
        if (FileHelpers.CheckImageExtension(UploadedImageFile.FileName))
        {
            string filename = UniqueFilename(UploadedImageFile.FileName);
            UploadedImageFile.SaveAs(FileImageFolder + filename);

            byte[]     data = ImageMedia.Create(UploadedImageFile.FileBytes).ToByteArray();
            FileStream file = File.Create(FileImageFolder + filename);
            file.Write(data, 0, data.Length);
            file.Close();

            BindImageList();
            ImageList.SelectedValue = filename;
            SelectImage(null, null);
        }
    }