Skip to content

This is a simple package used for generating the full encoded url to allow a user download access for a single file in a AWS S3 bucket.

Notifications You must be signed in to change notification settings

monde-sistemas/s3querybuilder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Self Destructing S3 Content Link Generator

GoDoc

License

Contributors: Mark Hayden
Tags: go, golang, s3, aws, amazon web services, s3querybuilder
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Overview

This is a simple package used for generating the full encoded url to allow an anonymous user to access a single file in a AWS S3 bucket. Generated link includes a expiration setting to ensure bucket security. Expiration is set by the second.

You can specify an HTTP verb such as PUT to allow users to upload an specific file, if no verb is specified it defaults to GET, allowing the file to be downloaded.

go get github.com/markhayden/s3querybuilder

Usage

Generate a URL which expires in 5 minutes to download a file from s3

	q := s3querybuilder.Cfg{
		File:      "file.txt",
		Bucket:    "my-s3-bucket",
		AccessKey: "<AWS_KEY>",
		SecretKey: "<AWS_KEY_SECRET>",
		Expire:    300,
	}
	fmt.Println(q.Link())

Generate a URL to upload a file to s3

	q := s3querybuilder.Cfg{
		File:      "file.txt",
		Bucket:    "my-s3-bucket",
		AccessKey: "<AWS_KEY>",
		SecretKey: "<AWS_KEY_SECRET>",
		HTTPVerb:  "PUT",
		Expire:    300,
	}
	fmt.Println(q.Link())

This will output the URL, you can use it with curl for example:

curl -v -X PUT --upload-file "file.txt" "<URL>"

Notice that you must put the URL inside double quotes or curl will not send all the query parameters.

About

This is a simple package used for generating the full encoded url to allow a user download access for a single file in a AWS S3 bucket.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%