# Puter WebDav
Puter's backend exposes a WebDav endpoint at /dav/. This document covers information relating to it.
## Support for webdav methods
* GET - Supported with Range headers in prod puter but without support for Range in Foss puter
* HEAD - Fully supported
* PUT - Supported, Content-Length required or x-expected-entity-length if Transfer Encoding is Chunked
* PROPFIND - Fully supported
* LOCK/UNLOCK - Stubbed
* Lock isn't supported in the backend but a fake lock token is returned for compatibility reasons.
* PROPPATCH - Stubbed
* Proppatching files does not do anything since Puter's filesystem doesn't support Extended attributes. All proppatches are returned as successful regardless.
* MKCOL - Fully working
* DELETE - Fully working
* COPY - Fully working
* MOVE - Fully working*
* move_coll test in Litmus
## Connecting guide
* Windows Native
* Click on This PC
* Click ... 
* Click Map Network Drive
<img height=200 src="https://hackmd.io/_uploads/SJbUXPHFge.png">
* Enter folder path as `https://api.puter.com/dav/YOUR_USERNAME`

* When prompted, enter username/password

* Use Mapped network drive as normal
* MacOS Native
* Open Finder

* In the Global Menu, click Go > Connect to server

* Enter URL as `https://api.puter.com/dav/YOUR_USERNAME`

* Click Connect, and then when prompted, click Connect once more

* When prompted, enter in your credentials

* Consider saving the password to your keychain. This will prevent you from needing to type your password in again
* Use the mounted folder as normal
* Rclone (Windows/macOS/linux)
* run `rclone mount --vfs-cache-mode writes :webdav: /mnt/puter --webdav-url "https://api.puter.com/dav/YOUR_USERNAME" --webdav-vendor other --webdav-user YOUR_USERNAME --webdav-pass $(rclone obscure "YOUR_PASSWORD")` replacing YOUR_USERNAME and YOUR_PASSWORD with your credentials.
* On Windows, you can replace /mnt/puter with a drive letter
* Linux davfs2
* Someone will have to try it and tell me
## 2fa
Generally, for 2fa you should be able to enter your password as your password and your token together. For example if your username was "user123", your password was "password", and your token was 456789, You would log in with:
```
Username: user123
Password: password456789
```
However some webdav clients improperly support cookies so after 30 seconds your session will become invalidated. To workaround this, we also support token auth.
To use Token Auth, go to https://puter.com/, and log into your account. From there, enter the developer tools and run `console.log(puter.authToken)`. This will log your authToken, copy this value for later.
When propted for your username and password, instead of entering them enter the following
```
Username: -token
Password: YOUR_AUTH_TOKEN_FROM_EARLIER
```
substituting YOUR_AUTH_TOKEN_FROM_EARLIER with the authToken obtained from https://puter.com/.
## Platform specific limitations
WebDav can be finnicky on different platforms. This section outlines known issues, and possible workarounds
### Windows
Microsoft Office 2019+ Can't open documents on WebDav, giving a security error.
* Workaround: Running `REG ADD HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\Common\Identity /t REG_EXPAND_SZ /v basichostallowlist /d "api.puter.com"` in admin CMD to restore the ability to do auth
* If no admin access, a third party WebDav tool such as rclone can be used to mount a folder without Windows recognizing it as WebDav fixing this error
Windows Explorer freezes up when you click a folder
* No workaround: Explorer lags terribly if there isn't a good network connection to any network drive.
The network path "https://api.puter.com/dav/YOUR_USERNAME" could not be found --OR-- The foler entered does not appear to be valid.
<img src="https://hackmd.io/_uploads/Sy-LLQIYle.png" height="200">
* Microsoft began disabling WebDav by default if you don't have a SharePoint share connected
* Fix: Open "services.msc" and find "WebClient"
<img src="https://hackmd.io/_uploads/ryzFL7UYxl.png" height=400>
* Double click service
* Set service to automatic
<img src="https://hackmd.io/_uploads/SJxzsLQLYlg.pngv" height=500>
* Click "Apply". Then click "Start" under Service Status.
* Connect normally
Cookies are broken sometimes. This affects 2fa users.
* Workaround: Use token login instead.
### macOS
WebDav connection is slow
* Reason: Apple spams lots of locks and fills/accesses a bunch of metadata stored in files in every folder
Viewing any folder fills the folder with junk `._filename` files
* Solution: WIP fix to reject macOS metadata
Some applications (such as quicktime player) wont open files on the WebDav drive
* Workaround: Use Rclone instead of native webdav client
### Rclone
Cookies are broken for WebDav. This affects 2fa users.
* Workaround: Use token login instead.