Ejemplo n.º 1
0
        public async Task <JsonResult> PutAsync(FullPath path, byte[] content)
        {
            var response = new ChangedResponseModel();

            // Write content
            await AzureStorageAPI.PutAsync(path.File.FullName, content);

            response.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(await Json(response));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> Rotate(string target, int degree)
        {
            FullPath path = ParsePath(target);

            RemoveThumbs(path);
            path.Root.PicturesEditor.Rotate(path.File.FullName, degree);
            var output = new ChangedResponseModel();

            output.Changed.Add((FileModel)BaseModel.Create(path.File, path.Root));
            return(await Json(output));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> Crop(string target, int x, int y, int width, int height)
        {
            FullPath path = ParsePath(target);

            RemoveThumbs(path);
            path.Root.PicturesEditor.Crop(path.File.FullName, x, y, width, height);
            var output = new ChangedResponseModel();

            output.Changed.Add((FileModel)BaseModel.Create(path.File, path.Root));
            return(await Json(output));
        }
Ejemplo n.º 4
0
        public async Task <JsonResult> PutAsync(FullPath path, byte[] content)
        {
            var response = new ChangedResponseModel();

            using (var fileStream = new FileStream(path.File.FullName, FileMode.Create))
                using (var writer = new BinaryWriter(fileStream))
                {
                    writer.Write(content);
                }
            response.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(await Json(response));
        }
Ejemplo n.º 5
0
        public async Task <ConnectorResult> PutAsync(FullPath path, string content)
        {
            var response = new ChangedResponseModel();

            using (var fileStream = new FileStream(path.File.FullName, FileMode.Create))
                using (var writer = new StreamWriter(fileStream))
                {
                    writer.Write(content);
                }
            response.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(new ConnectorResult(response));
        }
Ejemplo n.º 6
0
        public async Task <JsonResult> Put(string target, string content)
        {
            FullPath             fullPath = ParsePath(target);
            ChangedResponseModel answer   = new ChangedResponseModel();

            using (var fileStream = new FileStream(fullPath.File.FullName, FileMode.Create))
                using (var writer = new StreamWriter(fileStream))
                {
                    writer.Write(content);
                }
            answer.Changed.Add((FileModel)BaseModel.Create(fullPath.File, fullPath.Root));
            return(await Json(answer));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Сохранить текстовый документ
        /// </summary>
        /// <param name="target">Цель в формате elFinder</param>
        /// <param name="content">Текст</param>
        /// <param name="conv">Кодировка</param>
        async public Task <JsonResult> PutAsync(FullPath path, string content, string conv)
        {
            var response = new ChangedResponseModel();

            using (var fileStream = new FileStream(path.File.FullName, FileMode.Create))
            {
                using (var writer = new StreamWriter(fileStream, GetEncoding(conv)))
                {
                    writer.Write(content);
                }
            }
            response.Changed.Add((FileModel)await BaseModel.CreateAsync(this, path.File, path.RootVolume));
            return(Json(response));
        }
Ejemplo n.º 8
0
        public async Task <JsonResult> RotateAsync(FullPath path, int degree)
        {
            await RemoveThumbsAsync(path);

            // Crop Image
            ImageWithMimeType image;

            using (var stream = await path.File.OpenReadAsync())
            {
                image = path.RootVolume.PictureEditor.Rotate(stream, degree);
            }

            await AzureStorageAPI.PutAsync(path.File.FullName, image.ImageStream);

            var output = new ChangedResponseModel();

            output.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(await Json(output));
        }
        public async Task <JsonResult> CropAsync(FullPath path, int x, int y, int width, int height)
        {
            RemoveThumbs(path);

            // Crop Image
            ImageWithMimeType image;

            using (var stream = await path.File.OpenReadAsync())
            {
                image = path.RootVolume.PictureEditor.Crop(stream, x, y, width, height);
            }

            await AzureStorageAPI.Put(path.File.FullName, image.ImageStream);

            var output = new ChangedResponseModel();

            output.Changed.Add((FileModel)await BaseModel.Create(this, path.File, path.RootVolume));
            return(await Json(output));
        }
Ejemplo n.º 10
0
        public async Task <JsonResult> ResizeAsync(FullPath path, int width, int height)
        {
            await RemoveThumbsAsync(path);

            // Resize Image
            ImageWithMimeType image;

            await using (var stream = await path.File.OpenReadAsync())
            {
                image = path.RootVolume.PictureEditor.Resize(stream, width, height);
            }

            await AzureBlobStorageApi.PutAsync(path.File.FullName, image.ImageStream);

            var output = new ChangedResponseModel();

            output.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));

            return(await Json(output));
        }
Ejemplo n.º 11
0
        public async Task <JsonResult> CropAsync(FullPath path, int x, int y, int width, int height)
        {
            await RemoveThumbsAsync(path);

            // Crop Image
            ImageWithMimeType image;

            using (var stream = new FileStream(path.File.FullName, FileMode.Open))
            {
                image = path.RootVolume.PictureEditor.Crop(stream, x, y, width, height);
            }

            using (var fileStream = File.Create(path.File.FullName))
            {
                await image.ImageStream.CopyToAsync(fileStream);
            }

            var output = new ChangedResponseModel();

            output.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(await Json(output));
        }
Ejemplo n.º 12
0
        public async Task <ConnectorResult> RotateAsync(FullPath path, int degree)
        {
            await RemoveThumbsAsync(path);

            // Rotate Image
            ImageWithMimeType image;

            using (var stream = new FileStream(path.File.FullName, FileMode.Open))
            {
                image = path.RootVolume.PictureEditor.Rotate(stream, degree);
            }

            using (var fileStream = File.Create(path.File.FullName))
            {
                await image.ImageStream.CopyToAsync(fileStream);
            }

            var output = new ChangedResponseModel();

            output.Changed.Add(await BaseModel.CreateAsync(path.File, path.RootVolume));
            return(new ConnectorResult(output));
        }