{"id":18526698,"url":"https://github.com/rogusdev/onetime-downloader","last_synced_at":"2025-06-23T08:38:38.549Z","repository":{"id":142081045,"uuid":"279328191","full_name":"rogusdev/onetime-downloader","owner":"rogusdev","description":"Generate onetime download links for files stored in cloud storage","archived":false,"fork":false,"pushed_at":"2020-10-01T04:37:04.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T07:36:27.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogusdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-13T14:38:23.000Z","updated_at":"2020-09-18T02:50:50.000Z","dependencies_parsed_at":"2023-07-22T16:15:08.920Z","dependency_job_id":null,"html_url":"https://github.com/rogusdev/onetime-downloader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogusdev%2Fonetime-downloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogusdev%2Fonetime-downloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogusdev%2Fonetime-downloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogusdev%2Fonetime-downloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogusdev","download_url":"https://codeload.github.com/rogusdev/onetime-downloader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239242114,"owners_count":19605954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T17:52:13.862Z","updated_at":"2025-02-17T06:12:59.160Z","avatar_url":"https://github.com/rogusdev.png","language":"Rust","readme":"# onetime-downloader\nGenerate onetime download links for files stored in some kind of (cloud based?) storage\n\n## TODO:\n- [x] 2 api keys in header for curl: 1) add and list available files 2) create and list download links\n- [x] get endpoint returns json list of available files in storage\n- [x] post endpoint to add available file to storage\n- [x] post endpoint to create/store + return custom (random) url to download one of those files with tracking of use\n- [x] get endpoint to download file using custom url\n- [x] updated downloaded_at and prevent future downloads when downloading file\n- [x] get endpoint returns json list of available links for a given filename\n- [x] separate out modules into files and maybe folders (storage providers)\n- [ ] unit tests for ^\n- [x] dockerfile to run ^\n- [x] download header specifies filename!\n- [x] `expires_at` with default from env and optional override per link -- maybe default (for link) per file too?\n- [x] read filename from file, override with provided filename only if present\n- [x] update file if a new version is uploaded\n- [x] delete files + links\n- [ ] zero copy in links/files from input? (\u0026str not String)\n- [ ] JSON error responses when things go wrong\n- [ ] use `e.into()` for converting errors into `MyError`\n- [ ] react UI to manage list of files + links, etc\n- [ ] google sso to login for managing list -- remove api keys?...\n- [ ] audit trail of what actions taken by which users in ui\n- [ ] setup 3 subdomains: 1 for downloads, 1 for ui, 1 for api\n\n- [ ] rate limiting by IP that increases as more limits get triggered\n- [x] support storage provider: dynamodb\n- [x] support storage provider: postgres\n- [ ] support storage provider: redis\n- [ ] support storage provider: mongo\n- [ ] support other storage providers, plugin style: s3, gcs, azure blob, mysql, rds, aurora\n\n- [ ] google sso browser login to view list in UI\n- [ ] button to generate link for file in UI\n- [ ] support other SSO auth providers, plugin style\n\n\n## Setup\n\nDocker:\n```\ndocker network create www\n\ndocker rm -f onetime-downloader\ndocker build -t onetime-downloader .\ndocker run --env-file .env -e PG_HOST=postgres-www -p 8080:8080 --network=www --name onetime-downloader onetime-downloader\n\ndocker run -d --restart=always --env-file .env -e PG_HOST=postgres-www -e FILE_MAX_LEN=4000000 --network=www -l 'caddy'='downloads.chrisrogus.com' -l 'caddy.reverse_proxy'='$CONTAINER_IP:8080' --name onetime-downloader onetime-downloader\n\ndocker exec -it onetime-downloader bash\n```\n\n## Initialize\n\n### Postgres\n\n```\n--DROP SCHEMA IF EXISTS onetime CASCADE;\nCREATE SCHEMA IF NOT EXISTS onetime;\n\nCREATE TABLE IF NOT EXISTS onetime.files (\n    filename TEXT NOT NULL PRIMARY KEY,\n    contents BYTEA NOT NULL,\n    created_at BIGINT NOT NULL,\n    updated_at BIGINT NOT NULL\n);\nCREATE TABLE IF NOT EXISTS onetime.links (\n    token TEXT NOT NULL PRIMARY KEY,\n    filename TEXT NOT NULL,\n    note TEXT NULL,\n    created_at BIGINT NOT NULL,\n    expires_at BIGINT NOT NULL,\n    downloaded_at BIGINT,\n    ip_address TEXT\n);\n```\n\ndocker:\n```\ndocker rm -f postgres-www\ndocker run -d --restart=always -p 5432:5432 --network=www -v $PWD/postgres-data:/var/lib/postgresql --name postgres-www -e POSTGRES_PASSWORD=badpassword postgres:12.4-alpine\n\ndocker run -it --rm --network www postgres:12.4-alpine psql -h postgres-www -U postgres\npsql -h localhost -p 5432 -U postgres -d postgres\n\n\\d onetime.*\n```\n\n### Dynamodb\n\n```\naws dynamodb delete-table \\\n    --profile rogusdev-chris \\\n    --table-name Onetime.Links\n\n\naws dynamodb create-table \\\n    --profile rogusdev-chris \\\n    --table-name Onetime.Files \\\n    --attribute-definitions \\\n        AttributeName=Filename,AttributeType=S \\\n    --key-schema \\\n        AttributeName=Filename,KeyType=HASH \\\n    --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1\n\n#        AttributeName=Contents,AttributeType=B \\\n#        AttributeName=CreatedAt,AttributeType=N \\\n#        AttributeName=UpdatedAt,AttributeType=N \\\n\naws dynamodb create-table \\\n    --profile rogusdev-chris \\\n    --table-name Onetime.Links \\\n    --attribute-definitions \\\n        AttributeName=Token,AttributeType=S \\\n    --key-schema \\\n        AttributeName=Token,KeyType=HASH \\\n    --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1\n\n#        AttributeName=Filename,AttributeType=S \\\n#        AttributeName=CreatedAt,AttributeType=N \\\n#        AttributeName=DownloadedAt,AttributeType=N \\\n#        AttributeName=Ip,AttributeType=N \\\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogusdev%2Fonetime-downloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogusdev%2Fonetime-downloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogusdev%2Fonetime-downloader/lists"}