private-acl

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 10 Imported by: 0

README

Locked files

AWS S3 example where the files are non-public.

This file handler only responds to one user, "bob", but it illustrates how the logic can be extended to use a proper permission system to keep files "private".

Since the parameter acl=private is set, the credentials for this application have the only access to the files created through it.

See the canned ACL documentation for details.

Usage

Run the server

~$ go run ./examples/private-acl/...
listening on localhost:9000

Then test away using curl.

~$ curl  http://localhost:9000/everyone-elses-files/hello.txt
hi everyone
~$ curl  http://localhost:9000/bob-files/hello.txt
i don't know who you are
~$ curl -H 'private-acl-user: alice' \
    http://localhost:9000/bob-files/hello.txt
you're not bob
~$ curl -H 'private-acl-user: bob' \
    http://localhost:9000/bob-files/hello.txt
hi bob
~$ curl -H 'private-acl-user: bob' \
    -X POST \
    -d "body=Hello there I'm Bob." \
    http://localhost:9000/bob-files/bobs-first-file.txt
OK!
~$ curl http://localhost:9000/bob-files/bobs-first-file.txt
i don't know who you are
~$ curl -H 'private-acl-user: bob' \
    http://localhost:9000/bob-files/bobs-first-file.txt
Hello there I'm Bob.
~$ curl -H 'private-acl-user: bob' \
    -X DELETE \
    http://localhost:9000/bob-files/bobs-first-file.txt
Deleted bobs-first-file.txt

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL