Imports System.IO Imports System.Net Imports System.Security.Cryptography Imports System.Text Imports System.Web Module Upload Private Const ACCESS_KEY_ID As String = "xxxxxxxxxxxxxxxxxxxx" Private Const SECRET_ACCESS_KEY As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" REM Uploads a single file to PDF Alchemy. Sub UploadFile(ByVal filename As String) REM Trim filename to just the basename. Dim basename As String = filename If basename.LastIndexOf("\") >= 0 Then basename = basename.Substring(basename.LastIndexOf("\") + 1) End If Console.Write("Uploading '" & basename & "': ") REM Generate the HMAC-SHA1 signature. Dim timestamp As String = DateTime.UtcNow.ToString("r") Dim request As String = "/" & ACCESS_KEY_ID & "/inqueue/" & HttpUtility.UrlEncode(basename) Dim clearText As String = "PUT" & vbLf & ACCESS_KEY_ID & vbLf & timestamp & vbLf & request Dim hmac As HMACSHA1 = New HMACSHA1(ASCIIEncoding.UTF8.GetBytes(SECRET_ACCESS_KEY)) Dim signature As String = Convert.ToBase64String(hmac.ComputeHash(ASCIIEncoding.UTF8.GetBytes(clearText))) REM Upload the file to PDF Alchemy. Dim req As HttpWebRequest = HttpWebRequest.Create("https://www.pdfalchemy.com" & request) req.Method = "PUT" req.Headers.Add("X-PDF-Alchemy-Date", timestamp) req.Headers.Add("X-PDF-Alchemy-Signature", signature) Dim fileData As Byte() = File.ReadAllBytes(filename) Try Dim stream As Stream = req.GetRequestStream() stream.Write(fileData, 0, fileData.Length) stream.Close() Dim response As HttpWebResponse = req.GetResponse() Console.WriteLine(New StreamReader(response.GetResponseStream()).ReadToEnd()) response.Close() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub REM Uploads all convertable files from a single directory, to PDF Alchemy. Sub UploadFilesInDir(ByVal dirname As String) For Each filename As String In Directory.GetFiles(dirname) If filename.EndsWith(".doc") Or filename.EndsWith(".docx") Or filename.EndsWith(".rtf") Or filename.EndsWith(".txt") Then UploadFile(filename) End If Next End Sub Sub Main() For Each argument In My.Application.CommandLineArgs If Directory.Exists(argument) Then UploadFilesInDir(argument) Else UploadFile(argument) End If Next End Sub End Module