Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[DO NOT MERGE - PROTOTYPE] [Issue #22] Prototype download endpoint #68

Closed
wants to merge 2 commits into from

Conversation

chouinar
Copy link
Collaborator

@chouinar chouinar commented Jun 3, 2024

PROTOTYPE for discussion - will not be merged

Summary

Fixes #22

Time to review: 5 mins

Changes proposed

Setup an endpoint that returns a presigned S3 URL (as a redirect)

Localstack setup to have a mocked S3

Context for reviewers

Experimenting with a few ideas about how we handle a download endpoint. The simplest way I can think of is to put the files on S3, and return a presigned URL. Presigned URLs let users directly interact with S3 files, so we aren't actually handling the transfer of files, the users could download it directly from the source in a safe/secure manner.

The exact way we return the URL we can sort out later, while I did set this up as a redirect, I don't think that actually would be what we'd want. I think instead returning the URL in an ordinary response would be better. The frontend (or any users of the endpoint) could then download it in whatever manner they want.

Additional information

This is clunky to run, requires a bit of manual work, if you'd like to test this out, let me know and I'll help.

- EAGER_SERVICES_LOADING=1
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Maybe make sure to document specific LocalStack config or requirements in the project? Though it looks all baked into the image here

We won't need a license then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localstack has a community version that is free. Seems the main difference is which features are supported. S3 seems like its fully supported in community, so would work.

# TODO
start-localstack:
docker-compose up --detach localstack

Copy link
Collaborator

@rylew1 rylew1 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a brief comment on the command here on what we use localstack for

Copy link
Collaborator

@rylew1 rylew1 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also something in the docs that explains how to spin this up and test grabbing a file locally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a prototype - would add docs/connect properly in the makefile if I was going to merge this.

x = url.replace("localstack", "localhost")
print(x)

return redirect(x, 302)
Copy link
Collaborator

@rylew1 rylew1 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you write tests covering this endpoint? Also any logging we should do here? or exceptions that may occur on this route?

@chouinar
Copy link
Collaborator Author

chouinar commented Jul 8, 2024

Made an actual implementation here: #87 - so don't need this prototype anymore

@chouinar chouinar closed this Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: (Backend) Prototype a download endpoint
3 participants