- Aug
- 2,810
- 146
I use Clipb.in to share portions of text via the Internet.
File2Clipb.in.btm will take the contents of a text file,
and post it to ClipBin - Share Code or Text Instantly
Thus, I can post the contents of r:\stuff.txt to ClipBin - Share Code or Text Instantly as follows;
The contents of r:\stuff.txt will be removed after one day.
A URL is displayed for you to share with others.
This sample for using Clipb.in meets my needs,
but it may not meet yours.
The API for Clipb.in is available at ClipBin - Share Code or Text Instantly,
which allows you to modify File2Clipb.in.btm to your requirements.
Joe
File2Clipb.in.btm will take the contents of a text file,
and post it to ClipBin - Share Code or Text Instantly
Code:
@SETLOCAL
@ECHO OFF
if isdir r:\temp set temp=r:\temp
iff %# eq 0 then
echo USAGE: %_batchname r:\stuff.txt
quit
endiff
iff not exist %1 then
echo %1 does not exist.
quit
endiff
gosub Makeps1 > %temp\Clipb.in.ps1
pshell %temp\Clipb.in.ps1
ENDLOCAL
quit
:Makeps1
*type <<- endtext
$text = [System.IO.File]::ReadAllText("%1")
$body = @{
name = "%1"
text = $text
unlisted = "false"
remove = "day"
} | ConvertTo-Json
# Optional: verify exactly what will be sent
$body
$response = Invoke-RestMethod -Uri "https://clipb.in/api/post_data" -Method Post -ContentType "application/json; charset=utf-8" -Body $body
$url = "https://clipb.in/$($response.id)"
$url
endtext
Return
Thus, I can post the contents of r:\stuff.txt to ClipBin - Share Code or Text Instantly as follows;
Code:
R:\>File2Clipb.in.btm r:\stuff.txt
{
"remove": "day",
"unlisted": "false",
"name": "r:\\stuff.txt",
"text": "Line 1\r\nLine 2\r\nLine 3\r\nLine 4\r\n"
}
https://clipb.in/UKEewE_
R:\>
The contents of r:\stuff.txt will be removed after one day.
A URL is displayed for you to share with others.
This sample for using Clipb.in meets my needs,
but it may not meet yours.
The API for Clipb.in is available at ClipBin - Share Code or Text Instantly,
which allows you to modify File2Clipb.in.btm to your requirements.
Joe