Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/bulk-email/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
*.csv
uv.lock
106 changes: 0 additions & 106 deletions scripts/bulk-email/uv.lock

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/resume-downloader/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ACCOUNT_ID=
ACCESS_KEY_ID=
ACCESS_KEY=
CF=
BUCKET_NAME=
DOWNLOAD_PATH=./resumes
CSV_PATH=./users.csv
EVENT_ID=


2 changes: 2 additions & 0 deletions scripts/resume-downloader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uv.lock
users.csv
23 changes: 23 additions & 0 deletions scripts/resume-downloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Resume Downloader

Simple tool used for gathering all resumes from Cloudflare R2 and saving the file as the user's name.

## Setup

1. Clone the repository if you haven't
2. Install dependencies through uv (install uv first)
Run the following:
```
uv sync
```

3. Create a .env file. Copy the environment variables from .env.example

4. Get a csv file with a structure matching users.csv.example

## Usage

### Download all resumes corresponding to csv

uv run main.py

53 changes: 53 additions & 0 deletions scripts/resume-downloader/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import boto3
import os
import csv
from dotenv import load_dotenv

load_dotenv()

ACCOUNT_ID: str = os.getenv("ACCOUNT_ID", "")
ACCESS_KEY_ID: str = os.getenv("ACCESS_KEY_ID", "")
ACCESS_KEY: str = os.getenv("ACCESS_KEY", "")
BUCKET_NAME: str = os.getenv("BUCKET_NAME", "")
DOWNLOAD_PATH: str= os.getenv("DOWNLOAD_PATH", "")
CSV_PATH: str = os.getenv("CSV_PATH", "")
EVENT_ID: str = os.getenv("EVENT_ID", "")

def download_file_from_r2(client, bucket, key, download_path):
try:
client.download_file(bucket, key, download_path)
except Exception as e:
print(f"Error downloading '{bucket}/{key}': {e}")
return False

def main():
try:
s3 = boto3.client(
service_name="s3",
endpoint_url=f"https://{ACCOUNT_ID}.r2.cloudflarestorage.com",
aws_access_key_id=ACCESS_KEY_ID,
aws_secret_access_key=ACCESS_KEY,
# aws_account_id=ACCOUNT_ID,
region_name="auto",
)
print("R2 client initialized successfully.")

os.makedirs(os.path.dirname(DOWNLOAD_PATH), exist_ok=True)

with open(CSV_PATH, mode='r', newline='', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
folder = EVENT_ID
for row in reader:
id = row['id'].strip()
name = row['name'].strip()
key = f"{folder}/{id}"
filename= f"{DOWNLOAD_PATH}/{name}.pdf"
download_file_from_r2(s3, BUCKET_NAME, key, filename)
print(f"Saved {BUCKET_NAME}/{key}' to {filename}")

except Exception as e:
print(f"Failed to initialize R2 client or process files: {e}")

if __name__ == "__main__":
main()

10 changes: 10 additions & 0 deletions scripts/resume-downloader/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "bulk-email"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"python-dotenv>=1.1.1",
"boto3>=1.40.55",
]
3 changes: 3 additions & 0 deletions scripts/resume-downloader/users.csv.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"id","name",
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","FirstName_LastName",