Sign inSign up

e770r/sdc

By e770r

•Updated over 5 years ago

Image
0

1.0K

e770r/sdc repository overview

⁠My solution to the 2021 shopify developer challenge

⁠What i focused on
  • Adding images to the repository (supports single and bulk uploads)

  • Private/Public permissions

  • Securing uploading and storing images

Usage

The easiest way to get up and running with this project is with docker , for convinence i have created a public docker image

Pull the image

$ docker pull e770r/sdc

Run the server

$ docker run -d -p 8080:8080 sdc 

To make uploads you would need an account, so create one using the follwing curl command

$ curl -d '{"username":"batman", "password":"wootwoot"}' -H "Content-Type: application/json" -X POST http://localhost:8080/users/create | jq

Output account.png

Now you have an account you can make an upload

curl -u batman:wootwoot -X POST  -F "files[]=@./mycoolimage.jpg"  localhost:8080/public/upload    

Output

image

View all publicly available images

 curl localhost:8080/public/images | jq       

Output

public_images

Image uploads are secured by first validating the file extension and preventing a directory traversal attack⁠ using an in built function of flask.

Create a private image

$ curl -u batman:wootwoot -X POST  -F "files[]=@./secretimage.jpg"  localhost:8080/private/upload | jq 

Output

private_images

To get all images for the user . Make a get request to /private/images .

 curl -u batman:wootwoot localhost:8080/private/images | jq    

Response

{
  "Images": [
    "GtDc0D.jpg"
  ]
}

confirm your image is not public buy looking at all the images available

 curl localhost:8080/public/images | jq       
{
  "Images": [
    "jgpEke.jpg",
    "2klDay.jpg",
  ]
}

Tag summary

Content type

Image

Digest

Size

50.4 MB

Last updated

over 5 years ago

docker pull e770r/sdc