Uploading single files
The Vuture API includes a method that allows you upload a file into any Vuture folder in the website, email or print modules.
The API call is:
POST {Vuture_URL}/api/page.json?folderid={folder_id}&overwrite={true/false} (e.g.https://mycompany.vuturevx.com/api/page.json?folderid=123&overwrite=true)
the payload of the request should be the file to be uploaded with name="Files"
Parameter descriptions:
folderid: The id of the folder to be uploaded to. You can get this id by selecting the folder and hovering over the text "viewing folder"
overwrite: true/false - true will overwrite any existing file, false will not upload the new file
files: the files to be uploaded
You can test this using the Vuture API by browsing to {Vuture_URL}/api and scrolling down to click on the "Page" section and then finding the method called "Creates a page from file". Here you can enter the required values and browser for a file to test the API.
Uploading all the files in a folder
Using a simple Powershell 3.0 script you can automate the upload of all the files in one or more folders. The script below gives a sample implementation of this.
#requires -Version 3.0
Param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string[]] $folders,
[Parameter(Mandatory=$true)]
[string] $vuture_url,
[Parameter(Mandatory=$true)]
[string] $folderId,
[Parameter(Mandatory=$true)]
[string] $username,
[Parameter(Mandatory=$true)]
[string] $password
)
Process {
$boundary = [guid]::NewGuid()
$headers = @{
"Vx-Auth-Name" = $username;
"Vx-Auth-Password" = $password;
}
$folders | % {
gci $_ | % {
if (-not $_.PSIsContainer) {
$contents = gc $_.FullName
$body = @"
--$boundary
Content-Disposition: form-data; name="Files"; filename="$($_.Name)"
$contents
--$boundary--
"@
Write-Host "Uploading $($_.FullName)..."
$r = Invoke-RestMethod "$vuture_url/api/page.json?folderId=$folderId&overwrite=true" `
-Method "POST" `
-Headers $headers `
-Body $body `
-ContentType "multipart/form-data; boundary=$boundary"
}
}
}
}
Required parameters
folders = a comma separated list of the full folder paths for each folder you want to upload
vuture_url = the URL of your Vuture instance, e.g. https://mycompany.vuturevx.com
username = the username of a valid Vuture user that has access to the folder you are trying to upload to
password = the password of the user above
Note that using the API does not prompt for a password change when passwords are due to expire so as long as the credentials above are not used for a normal login the API call will continue to work
Sample usage
Save the script above to a file called "vuture_upload.ps1"
Open a command prompt in windows and navigate to the folder you saved the script above into.
Type "@powershell" (without the quote) to start PowerShell. Note you need to have version 3 of PowerShell installed.
Enter ".\vuture_upload.ps1 -folders C:\Users\my.name\Desktop\myFiles -vuture_url https://mycompany.vuturevx.com -Username my.name@company.com -Password myPassword -folderId 123"
where:
C:\Users\my.name\Desktop\myFiles is the folder with the files to be uploaded. More folders can be added separated by a comma
https://mycompany.vuturevx.com is my Vuture URL
my.name@company.com is the Vuture login to be used. We recommend setting up a dedicated login if this is to be used for a regular task
myPassword is the password for the account below
folderId is the id of the folder to be uploaded to