mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 18:19:32 +02:00
Improve publish-to-ipfs.ps1
This commit is contained in:
parent
f7d5d366f7
commit
dc6b183696
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Publishes the given files or directory to IPFS
|
Publishes the given files and folders to IPFS
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
||||||
.LINK
|
.LINK
|
||||||
@ -20,23 +20,29 @@ try {
|
|||||||
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
||||||
|
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
$Files = (get-childItem "$Files")
|
if (test-path "$Files" -pathType container) {
|
||||||
[int]$Count = $Files.Count
|
"Adding folder $Files to IPFS..."
|
||||||
foreach ($File in $Files) {
|
[int]$Count = 1
|
||||||
if (test-path "$File" -pathType container) {
|
& ipfs add -r "$Files" > $HashList
|
||||||
"Adding directory tree $File to IPFS..."
|
|
||||||
ipfs add -r "$File" > $HashList
|
|
||||||
|
|
||||||
echo "Calculating digital forensics hashes to $DF_HASHES ..."
|
echo "Calculating digital forensics hashes to $DF_HASHES ..."
|
||||||
nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$File" > $DF_Hashes
|
& nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$Files" > $DF_Hashes
|
||||||
} else {
|
} else {
|
||||||
"Adding file $File to IPFS..."
|
$FileList = (get-childItem "$Files")
|
||||||
ipfs add "$File" > $HashList
|
[int]$Count = $FileList.Count
|
||||||
|
foreach ($File in $FileList) {
|
||||||
|
if (test-path "$Files" -pathType container) {
|
||||||
|
"Adding folder $File to IPFS..."
|
||||||
|
& ipfs add -r "$File" >> $HashList
|
||||||
|
} else {
|
||||||
|
"Adding file $File to IPFS..."
|
||||||
|
& ipfs add "$File" >> $HashList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ published $Count files(s)/directory to IPFS in $Elapsed sec"
|
"✔️ published $Count file(s)/folder(s) to IPFS in $Elapsed sec"
|
||||||
" NOTE: to publish it to IPNS execute: ipfs name publish <HASH>"
|
" NOTE: to publish it to IPNS execute: ipfs name publish <HASH>"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user