我正在尝试为.bashrc创建一个脚本,该脚本适用于匿名文件上传服务file.io ...
这是我一直在使用的内容,但这是用于transfer.sh的服务:
# anonymous file uploading to transfer.sh via command line ($ upload file.any)
upload() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }
效果很好!但是来自file.io网站的以下代码对我没有帮助。我觉得我已经尝试了一切,但是到目前为止我并不是最擅长编码的人。
curl -F "file=test.txt" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
我尝试了很多不同的东西,第一个是:(还有许多不同的变体)
upload2 () {
curl -F "file=$1" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
}
有人可以帮助我学习吗?
答案 0 :(得分:0)
以下对我有用。
Sub IAmCaller()
TestExcel({"Sheet1", "Sheet2", "Sheet3"}) '//Pass sheets' names
End Sub
Sub TestExcel(SheetsNames As String())
Dim xlApp As Excel.Application = New Excel.Application With {.Visible = False}
If xlApp Is Nothing Then
WriteLine("Excel is not properly installed!!")
Return
End If
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim xlTempBook As Excel.Workbook
Dim xlTempSheet As Excel.Worksheet
Dim xlRange As Excel.Range
'// This variable will hold the last row where data will be inserted
Dim lastRow As Long
xlWorkBook = xlApp.Workbooks.Open("C:\Master.xlsx")
'// Either create new workbook based on default template or your own template:
'// Default template
xlTempBook = xlApp.Workbooks.Add()
'// Your own template
xlTempBook = xlApp.Workbooks.Add(xlApp.TemplatesPath + "NEWTEMPLATE.xltx")
'// First sheet of temp workbook
xlTempSheet = xlTempBook.Sheets(1)
For Each sheetName In SheetsNames
'// Select some range and copy to new sheet in new temp book
xlRange = xlWorkBook.Sheets(sheetName).Range("A1:C10")
'// Calculate last row
With xlTempSheet
'// We calculate last row by column A.
'// Feel free to change it to appropriate one.
lastRow = .Cells(.Rows.Count, "A").End(Excel.XlDirection.xlUp).Row
'// Next empty cell.
'// Then End method (above) returns last cell.
'// If sheet is clear, then the last cell is always in the first row.
'// However, if there's some data, then last cell won't be the first.
'// In this case we need to make a shift one cell down.
If lastRow > 1 Then lastRow += 1
'// Actual copying.
'// In this case we copy into A column (i.e. top-left cell).
'// As your master range contains formulas and you don't need them,
'// you have two choices:
'// 1) Use clipboard
'// 2) Use Value property
'// The first one is easy to implement.
'// The second one requires accepting side to have same form,
'// i.e. the accepting range must have same number of rows and columns.
'// Case 1. Using clipboard.
xlRange.Copy() : .Cells(lastRow, "A").PasteSpecial(Excel.XlPasteType.xlPasteValues)
'// Case 2. Using Value property
.Cells(lastRow, "A").Resize(xlRange.Rows.Count, xlRange.Columns.Count).Value = xlRange.Value
End With
Next
xlTempBook.SaveAs("C:\New.CSV", Excel.XlFileFormat.xlCSV)
xlTempBook.Close(False)
xlWorkBook.Close(False)
xlApp.Quit()
xlRange = Nothing
xlWorkSheet = Nothing
xlWorkBook = Nothing
xlApp = Nothing
GC.Collect()
GC.WaitForFullGCComplete()
GC.Collect()
GC.WaitForFullGCComplete()
WriteLine("Excel file created , you can find the file C:\New.CSV")
End Sub
然后您可以使用upload2(){
curl -F "file=@$1" https://file.io
}
并得到响应:
upload2 Testfile