Example #1
0
        public async Task <IWebDavResult> CreateCollectionAsync(WebDavContext context)
        {
            string fullpath = GetLocalPath(context.Path);

            DirectoryInfo dir = Directory.CreateDirectory(fullpath);

            return(new WebDavNoContentResult(HttpStatusCode.Created));
        }
Example #2
0
        public async Task <bool> MoveToAsync(WebDavContext context, string path)
        {
            string localPathFrom = GetLocalPath(context.Path);
            string localPathTo   = GetLocalPath(path);

            Directory.Move(localPathFrom, localPathTo);

            return(true);
        }
Example #3
0
        public async Task WriteFileAsync(Stream stream, WebDavContext context)
        {
            FileInfo file = new FileInfo(GetLocalPath(context.Path));

            using (Stream fs = file.OpenWrite())
            {
                //clear content
                fs.SetLength(0);

                await stream.CopyToAsync(fs);
            }
        }
Example #4
0
 public override XElement ToXml(WebDavContext context)
 {
     return(new XElement(dav + "response",
                         new XElement(dav + "href", $"{context.BaseUrl}/{DisplayName}"),
                         new XElement(dav + "propstat",
                                      new XElement(dav + "prop",
                                                   new XElement(dav + "displayname", DisplayName),
                                                   new XElement(dav + "getcontentlength", $"{Length}"),
                                                   new XElement(dav + "creationdate", $"{CreatedAt:yyyy-MM-ddTHH:mm:sszzz}"),
                                                   new XElement(dav + "getlastmodified", $"{ModifiedAt:yyyy-MM-ddTHH:mm:sszzz}")
                                                   ))
                         ));
 }
Example #5
0
 public override XElement ToXml(WebDavContext context)
 {
     return(new XElement(dav + "prop",
                         new XAttribute(XNamespace.Xmlns + "d", dav),
                         new XElement(dav + "lockdiscovery",
                                      new XElement(dav + "activelock",
                                                   new XElement(dav + "lockscope",
                                                                new XElement(dav + "exclusive")),
                                                   new XElement(dav + "locktype",
                                                                new XElement(dav + "write")),
                                                   new XElement(dav + "depth", "Infinity"),
                                                   new XElement(dav + "timeout", "Second-604800"),
                                                   new XElement(dav + "locktoken",
                                                                new XElement(dav + "href", $"opaquelocktoken:{Id}")))
                                      )));
 }
Example #6
0
        public async Task <IWebDavResult> FindPropertiesAsync(WebDavContext context)
        {
            string fullpath = GetLocalPath(context.Path);

            //is directory
            if (Directory.Exists(fullpath))
            {
                return(new WebDavCollectionsResult(new DirectoryInfo(fullpath)));
            }
            //is file
            else if (File.Exists(fullpath))
            {
                return(new WebDavFile(new FileInfo(fullpath)));
            }
            //not found
            else
            {
                return(new WebDavFileNotFoundResult());
            }
        }
Example #7
0
 public override XElement ToXml(WebDavContext context)
 {
     return(new XElement("NotFound"));
 }
 public static void SetWebDavContext(this HttpContext httpContext, WebDavContext webDavContext)
 {
     httpContext.Items.Add("WebDavContext", webDavContext);
 }
Example #9
0
 public async Task <bool> DeleteAsync(WebDavContext context)
 {
     return(false);
 }
Example #10
0
 public async Task <IWebDavResult> PatchPropertiesAsync(WebDavContext context)
 {
     throw new NotImplementedException();
 }
Example #11
0
        public async Task <Stream> OpenFileStreamAsync(WebDavContext context)
        {
            FileInfo file = new FileInfo(GetLocalPath(context.Path));

            return(file.OpenRead());
        }
Example #12
0
 public abstract XElement ToXml(WebDavContext context);