Jetzt möchte ich meine Kontaktinformationen ohne zusätzliche App mit dem Adressbuch meines Smartphones synchronisieren. Ich wähle WebDAV, um dies zu erreichen.
Das Problem ist, dass ich aufgrund des benutzerdefinierten HttpAttribute wie PROPFIND. Kennt jemand eine Lösung zum Hinzufügen von WebDAV?
Das ist mein Controller:
Code: Select all
using Microsoft.AspNetCore.Mvc;
namespace Playground.Controllers
{
[Route("api/webdav")]
[ApiController]
public class WebDAVController : ControllerBase
{
private readonly string _baseDirectory = Path.Combine(Directory.GetCurrentDirectory(), "WebDAVData");
public WebDAVController()
{
// Ensure base directory exists
if (!Directory.Exists(_baseDirectory))
{
Directory.CreateDirectory(_baseDirectory);
}
}
// PROPFIND - Retrieve properties (a simple version)
[AcceptVerbs("PROPFIND")]
public IActionResult Propfind([FromQuery] string path)
{
var fullPath = Path.Combine(_baseDirectory, path ?? "");
if (!System.IO.File.Exists(fullPath) && !Directory.Exists(fullPath))
{
return NotFound();
}
// Return file or folder properties (you can extend this to include more detailed properties)
var fileInfo = new FileInfo(fullPath);
var properties = new Dictionary
{
{ "CreationDate", fileInfo.CreationTime.ToString() },
{ "LastModified", fileInfo.LastWriteTime.ToString() },
{ "Size", fileInfo.Length.ToString() }
};
return Ok(properties);
}
}
}