Skip to content

CLI util command to upload to any cloud platform storage/bucket using the Go CDK.

License

Notifications You must be signed in to change notification settings

BHunter2889/upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

upload

A CLI util for uploading documents to bucket storage on AWS, GCP, and Azure cloud native platforms.


Usage

uploads 1904logo.png to GCS

$ upload 'gs://your-cnp-bucket' 1904logo.png
or
$ upload gcs 'your-cnp-bucket' 1904logo.png

uploads 1904logo.png to S3

$ upload 's3://your-cnp-bucket' 1904logo.png
or
$ upload s3 'your-cnp-bucket' 1904logo.png
or
$ upload s3 'your-cnp-bucket' 1904logo.png -r 'us-east-1'

uploads 1904logo.png to Azure

$ upload 'azblob://your-cnp-bucket' 1904logo.png
or
$ upload azure 'your-cnp-bucket' 1904logo.png

uploads 1904logo.png to a Local bucket directory

Per documentation, this is primarily for testing purposes but can be used as an alternative for some file transfers.
$ upload 'file:///path/to/your-local-bucket' 1904logo.png
or
$ upload local /path/to/your-local-bucket 1904logo.png

uploads 1904logo.png to all CNP storage providers

Requires that the target buckets for a single command have the same name on all platforms.
An exception to the above is when including Local by providing the -l or --local flag which should be immediately followed by the path to the target directory for local 'upload' only which can have any name even if different from the name specified for this all subcommand.

$ upload all 'your-cnp-bucket' 1904logo.png
or w/ Local option:
$ upload all 'your-cnp-bucket' 1904logo.png -l /path/to/your-local-bucket
or w/ alternate specified AWS region for S3:
$ upload all 'your-cnp-bucket' 1904logo.png -r 'us-east-1'

help

$ upload
$ upload -h
$ upload --help
$ upload help s3
$ upload s3 --help

Prerequisites

  • For uploading to your preferred or various Cloud platforms, see this section for uploading an image within the Go CDK tutorial.

    • For AWS, you will need to set your default region (i.e. us-east-1), but if it is appended to the url, this upload util will use the appended region instead (i.e. 's3://your-cnp-bucket?region=us-east-1').
  • You will also likely need some additional setup not included in the tutorial such as installing and configuring the aws cli util and setting up your credentials and other environment variables for your respective platforms.

    • This is necessary because the Go CDK looks for these credentials based on the storage/bucket url you provide. Under the hood, the Go CDK makes use of the respective cli utils and configuration for the targeted platform
  • Note: If you plan on building the binary yourself (included upload binary is up-to-date), you will need to have the Go >=1.11 development environment setup with Go modules enabled.

    • On this note, Pull Requests and new issue tickets are welcome!

Building

  • For convenience, a Makefile has been provided to cut out repetitive steps when tweaking or customizing the util. This is used primarily to trim down the produced binary size and implement best practices. Build this util simply by executing make build .

Invoke from anywhere as a CLI Command:

  • Copy the produced binary to a /bin somewhere on your path (i.e. ~/bin).
    • example: $ cp upload ~/bin/upload
    • Note: make deploy will build the binary and copy it to your ~/bin directory for you if it exists.

Credit

  • This is taken from the Go CDK Tutorial. This repo has been modified from the tutorial example to streamline the usage and provide additional explanation.
  • Extended to introduce subcommands for each CNP as well as help & -h command features using the Cobra CLI framework.

About

CLI util command to upload to any cloud platform storage/bucket using the Go CDK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published