Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upload to transfer.sh from Powershell
function transfer ($filename)
{
$file = Get-Item $filename;
invoke-webrequest -method put -infile $file.FullName https://transfer.sh
}
"Test" | Set-Content .\test.txt
transfer(".\test.txt")
@t0nik0

This comment has been minimized.

Copy link

@t0nik0 t0nik0 commented Dec 14, 2019

I've added the short filename as "$($file.Name)" and write link to the file to stdout:

function transfer.sh ($filename)
{
  $file = Get-Item $filename;
  (Invoke-WebRequest -Method PUT -InFile $file.FullName -Uri https://transfer.sh/$($file.Name)).Content
}

PS C:\tmp> "Test" | Set-Content .\test.txt
PS C:\tmp> transfer.sh .\test.txt
https://transfer.sh/2k60s/test.txt
PS C:\tmp>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment