Ejemplo n.º 1
0
        public override void Resize(string file, int width, int height)
        {
            ImageWithMime output;
            var           content = client.Download(file);

            using (var ms = new MemoryStream(content))
            {
                using (Image inputImage = Image.FromStream(ms))
                {
                    output = ScaleOrCrop(inputImage, new Rectangle(0, 0, inputImage.Width, inputImage.Height), new Rectangle(0, 0, width, height));
                }

                client.Upload(file, output.ImageStream);
            }
        }
Ejemplo n.º 2
0
        JsonResult IDriver.Get(string target)
        {
            target = this.GetCorectTarget(target);
            string      decodedTarget = this.DecodeTarget(target);
            GetResponse answer        = new GetResponse();

            answer.Content = Encoding.Default.GetString(client.Download(decodedTarget));
            return(Json(answer));
        }
Ejemplo n.º 3
0
        public static bool FileExist(string fileUri, Guid token)
        {
            var          _authService = new AuthorizeServiceClient();
            WebDavClient webDavClient = InitWebDav(token, _authService);
            var          fileInfo     = new FileInfo(fileUri);
            bool         result       = true;

            byte[] file = webDavClient.Download(fileUri);
            //List<DirInfo> dirInfos = webDavClient.GetDirectories(fileInfo.Directory.Name);
            //bool result=dirInfos.Any(x => x.IsDirectory == false && x.DisplayName.Equals(fileInfo.Name));
            if (file == null)
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult DownloadFile(string downloadedFileUri)
        {
            Guid token = CheckSessionAuthState(CurrentUser, _authService);

            if (token == Guid.Empty)
            {
                return(RedirectToAction("LogOff", "Account"));
            }

            string filenameForFF         = downloadedFileUri;
            var    downloadedFileUriInfo = new FileInfo(downloadedFileUri);
            string fileName = HttpUtility.UrlEncode(downloadedFileUriInfo.Name).Replace(@"+", @"%20");


            if (Request.Browser.Browser == "Firefox")
            {
                fileName = filenameForFF;
            }
            if (!string.IsNullOrEmpty(fileName))
            {
                WebDavClient webDavClient = Helper.InitWebDav(token, _authService);
                //new WebDavClient(downloadedFileUri, Model.UserInfo.User.Login, Model.UserInfo.User.Password);
                byte[] retfile = webDavClient.Download(downloadedFileUri);
                if (webDavClient.LastError != null)
                {
                    throw new HttpException(404,
                                            " Ошибка чтения исходного файла" + fileName + " : " + webDavClient.LastError);
                }
                return(File(retfile, "application/octet-stream", fileName));
            }
            if (Request.IsAjaxRequest())
            {
                return
                    (Json(
                         new
                {
                    status = "Error",
                    errorCode = "",
                    errorMessage = " Ошибка чтения исходного файла" + fileName
                }, JsonRequestBehavior.AllowGet));
            }
            throw new HttpException(404, " Ошибка чтения исходного файла" + fileName);
        }
        public async Task <StorageFile> DownloadAsync(BaseItem davItem, StorageFolder folder, CancellationToken token, Progress <HttpProgress> progress)
        {
            var         client = new WebDavClient(new Uri(Configuration.ServerUrl, UriKind.RelativeOrAbsolute), Configuration.Credential);
            StorageFile file;
            Uri         uri;

            if (davItem.IsCollection)
            {
                file = await folder.CreateFileAsync(davItem.DisplayName + ".zip", CreationCollisionOption.OpenIfExists);

                uri = new Uri(GetZipUrl(davItem.EntityId));
            }
            else
            {
                file = await folder.CreateFileAsync(davItem.DisplayName, CreationCollisionOption.OpenIfExists);

                uri = new Uri(davItem.EntityId, UriKind.RelativeOrAbsolute);
            }
            await client.Download(uri, file, token, progress);

            return(file);
        }