Skip to content

Instantly share code, notes, and snippets.

@r4dian
Last active March 16, 2024 14:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save r4dian/47c60f43fcfc68059cbe to your computer and use it in GitHub Desktop.
Save r4dian/47c60f43fcfc68059cbe to your computer and use it in GitHub Desktop.
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
Copy link

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