Skip to content

Commit

Permalink
Add access key option
Browse files Browse the repository at this point in the history
  • Loading branch information
andreimarcu committed Mar 10, 2020
1 parent ae19b9b commit 11d4fec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Options
- ```-e 600``` -- Time until file expires in seconds
- ```-deletekey mysecret``` -- Specify deletion key
- ```-o``` -- Overwrite file if you have its deletion key
- ```-accesskey mykey``` -- Specify access key
- ```-c myconfig.json``` -- Use non-default config file (can be useful if using more than one linx-server instance). This option will create a config if file does not exist.
- ```-no-cb``` -- Disable automatic insertion into clipboard
- ```-selif``` -- Return selif url (direct url)
Expand Down
10 changes: 8 additions & 2 deletions linx.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
var overwrite bool
var expiry int64
var deleteKey string
var accessKey string
var desiredFileName string
var configPath string
var noClipboard bool
Expand All @@ -63,6 +64,8 @@ func main() {
"Time in seconds until file expires (ex: -e 600)")
flag.StringVar(&deleteKey, "deletekey", "",
"Specify your own delete key for the upload(s) (ex: -deletekey mysecret)")
flag.StringVar(&accessKey, "accesskey", "",
"Specify an access key to limit access to the file with a password")
flag.StringVar(&desiredFileName, "f", "",
"Specify the desired filename if different from the actual filename or if file from stdin")
flag.StringVar(&configPath, "c", "",
Expand All @@ -84,12 +87,12 @@ func main() {
}
} else {
for _, fileName := range flag.Args() {
upload(fileName, deleteKey, randomize, expiry, overwrite, desiredFileName, noClipboard, useSelifURL)
upload(fileName, deleteKey, accessKey, randomize, expiry, overwrite, desiredFileName, noClipboard, useSelifURL)
}
}
}

func upload(filePath string, deleteKey string, randomize bool, expiry int64, overwrite bool, desiredFileName string, noClipboard bool, useSelifURL bool) {
func upload(filePath string, deleteKey string, accessKey string, randomize bool, expiry int64, overwrite bool, desiredFileName string, noClipboard bool, useSelifURL bool) {
var reader io.Reader
var fileName string
var ssum string
Expand Down Expand Up @@ -140,6 +143,9 @@ func upload(filePath string, deleteKey string, randomize bool, expiry int64, ove
if deleteKey != "" {
req.Header.Set("Linx-Delete-Key", deleteKey)
}
if accessKey != "" {
req.Header.Set("Linx-Access-Key", accessKey)
}
if randomize {
req.Header.Set("Linx-Randomize", "yes")
}
Expand Down

0 comments on commit 11d4fec

Please sign in to comment.