Exemple #1
0
        public async Task<byte[]> GetImagebyte(HttpRequestMessage request)
        {
            byte[] bytes = null;

            var provider = new PictureMultipartFormDataStreamProvider(this.WorkingFolder);

            await request.Content.ReadAsMultipartAsync(provider);

            foreach (var file in provider.FileData)
            {
                var fileInfo = new FileInfo(file.LocalFileName);

                bytes = System.IO.File.ReadAllBytes(file.LocalFileName);

            }

            return bytes;

        }
Exemple #2
0
        public async Task<IEnumerable<PictureView>> Add(HttpRequestMessage request)
        {
            var provider = new PictureMultipartFormDataStreamProvider(this.WorkingFolder);

            await request.Content.ReadAsMultipartAsync(provider);

            //string targetPath = @"C:\Users\Public\TestFolder\SubDir";


            var pictures = new List<PictureView>();

            foreach (var file in provider.FileData)
            {
                var fileInfo = new FileInfo(file.LocalFileName);

                byte[] bytes = System.IO.File.ReadAllBytes(file.LocalFileName);

                pictures.Add(new PictureView
                {
                    Name = fileInfo.Name,
                    Created = fileInfo.CreationTime,
                    Modified = fileInfo.LastWriteTime,
                    Size = fileInfo.Length / 1024
                });
            }

            return pictures;
        }