Skill 54 · Ingesting Into Data Lake
Subchapter 54.17
references/local-upload.mdMarkdown5 KBView on GitHub
Upload files from the local filesystem to S3, with optional ingestion into a table.
First, check the source path. If the user provides an S3 URI (e.g., s3://...) as the source, stop and use s3-files.md instead. This workflow is for local files only.
Parse the user’s request to route:
If ambiguous and the file is structured (CSV, JSON, Parquet, TSV, Avro, ORC), ask: “Do you want this queryable as a table, or just stored in S3?”
ls -lh for files, du -sh for directorieshead -5 to check headers, delimiter, encodinghead -20 to check structure (records vs. arrays)Encoding check (CSV/TSV/JSON only):
file --mime-encoding <path>If not UTF-8 or ASCII, warn the user before upload. Non-UTF-8 files can cause downstream parsing failures.
Ask for target bucket or list available buckets:
aws s3 lsSuggest prefix structure: s3://<bucket>/<domain>/<dataset>/<filename>
Confirm with user before uploading
Default: preserve original filename. Override: user specifies a different key.
Single file – check for existing objects before uploading (aws s3 cp silently overwrites):
aws s3 ls s3://<bucket>/<prefix>/<filename>If the object exists, warn the user and get explicit confirmation before proceeding.
Directory – check for existing objects before syncing. Use a bounded existence check to avoid enumerating every object under the prefix (which can be very slow on large prefixes):
aws s3api list-objects-v2 --bucket <bucket> --prefix <prefix>/ --max-items 1If the result contains any Contents, objects exist and the user should be warned before proceeding. aws s3 sync skips unchanged files but overwrites modified ones without prompting.
Single file upload:
aws s3 cp <local-path> s3://<bucket>/<prefix>/<filename>Directory upload:
aws s3 sync <local-dir> s3://<bucket>/<prefix>/For files over 8 MB, aws s3 cp uses multipart upload automatically. No special flags needed.
Verify upload:
aws s3 ls s3://<bucket>/<prefix>/<filename>Report results and stop:
aws s3 cp s3://... .After upload completes, continue with the s3-files.md workflow using:
Do not reimplement schema inference or table creation – follow the S3 files workflow for those steps.
aws s3 cp silently overwrites existing S3 objects. Always check first.aws s3 sync skips unchanged files but overwrites modified ones without prompting. Check destination before syncing directories.screen or tmux session.| Error | Cause | Fix |
|---|---|---|
upload failed: ... An error occurred (AccessDenied) | No write permission to target bucket | Check IAM policy or bucket policy allows s3:PutObject |
The user-provided path ... does not exist | Typo in local path | Verify path with ls |
fatal error: An error occurred (NoSuchBucket) | Bucket does not exist | List buckets with aws s3 ls and pick an existing one |
| Upload hangs or is very slow | Large file on slow connection | Check file size, suggest tmux/screen, verify network |