Tag Archives: http

WebDAV with cURL

Assuming the following Data:

  • Webdav URL: http://example.com/webdav
  • Username: user
  • Password: pass


Reading Files/Folders

curl 'http://example.com/webdav'

Creating new Folder

curl -X MKCOL 'http://example.com/webdav/new_folder'

Uploading File

curl -T '/path/to/local/file.txt' 'http://example.com/webdav/test/new_name.txt'

Renaming File

curl -X MOVE --header 'Destination:http://example.org/webdav/new.txt' 'http://example.com/webdav/old.txt'

Deleting Files/Folders


curl -X DELETE 'http://example.com/webdav/test.txt'


curl -X DELETE 'http://example.com/webdav/test'

List Files in a Folder

curl -i -X PROPFIND http://example.com/webdav/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">

Continue reading WebDAV with cURL

vbs http download

Dim Hostname, fso, CurrentDirectory
Set wshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

CurrentDirectory = fso.GetAbsolutePathName(".")

Hostname = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

WScript.Echo "HOSTNAME: " & Hostname

HTTPDownload "http://example.com/" & Hostname & ".txt", CurrentDirectory

Sub HTTPDownload(myURL, myPath)
	' Standard housekeeping
	Dim i, objFile, objFSO, objHTTP, strFile
	Const ForReading = 1, ForWriting = 2, ForAppending = 8

	' Create a File System Object
	Set objFSO = CreateObject("Scripting.FileSystemObject")

	' Check if the specified target file or folder exists,
	' and build the fully qualified path of the target file
	If objFSO.FolderExists(myPath) Then
		strFile = objFSO.BuildPath(myPath, Mid(myURL, InStrRev(myURL, "/") + 1))
	ElseIf objFSO.FolderExists(Left(myPath, InStrRev(myPath, "\") - 1)) Then
		strFile = myPath
		WScript.Echo "ERROR: Target folder not found."
		Exit Sub
	End If

	' Create or open the target file
	Set objFile = objFSO.OpenTextFile(strFile, ForWriting, True)

	' Create an HTTP object
	Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

	' Download the specified URL
	objHTTP.Open "GET", myURL, False

	' Write the downloaded byte stream to the target file
	For i = 1 To LenB(objHTTP.ResponseBody)
		objFile.Write Chr(AscB(MidB(objHTTP.ResponseBody, i, 1)))

	' Close the target file
End Sub