Copy files to R2 and link them (paid)
nc_filesCopies every file and image the loaded data points at from the source's storage into the customer's R2 bucket, stored under its content hash (the same file is stored once). Records old URL to new key in the file_map table, fills each file field's key column, and keeps the old URL in its legacy column. Links inside text, rich text and JSON are copied too, and replaced by the app's file route (a list of files holds bare keys); the originals are backed up in text_url_backup (rewrite_text: false turns the replacing off). Every link ends copied or listed as failed with its reason, and the step is not done while any link to the old storage has no outcome. Only the source platform's own storage is copied unless allow_hosts adds more. Resumable: each call does a bounded batch and returns status partial until done. Paid: needs a pass for the app, or the free trial for plans up to 1,000 records.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"job_id": "<job_id>"
},
"name": "nc_files"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | No | R2 bucket for the files. Default: the staging bucket. | |
| job_id | Yes | ||
| rewrite | No | Fill the key columns once a file is copied. Default true. | |
| upgrade | No | Set true to pay the difference to the next pass that fits, only when the app is past its pass's (or free trial's) record or file limit. | |
| go_ahead | No | Set true only when a charge applies, once the owner has seen the estimate and agreed to it. Not needed under the free trial or a pass that already covers the app. Needed again after a pass has expired. | |
| max_bytes | No | Largest file to copy. Default 50 MB. | |
| max_files | No | Files per call. Default 15. | |
| r2_bucket | No | An R2 bucket in that account, for staging and schema files. | |
| job_secret | No | The job_secret returned when this job was made (or the job's signed editor link). Required with job_id when no API key is sent: the job_id alone does not open a job. | |
| url_prefix | No | Prefix for rewritten text links. Default /api/files/ (the generated app's file route). | |
| allow_hosts | No | Extra hosts to copy from, for example images.example.com. Links to other hosts are listed, not copied. | |
| cf_api_token | No | A Cloudflare API token with D1 edit permission on that account. Sealed in the job, deleted when it ends. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. | |
| retry_failed | No | Try again the files that failed or were skipped earlier. | |
| rewrite_text | No | Replace links inside text values with url_prefix plus the new key (a list of files gets the bare key). Originals go to text_url_backup. Default true. | |
| cf_account_id | No | The customer's Cloudflare account id. | |
| r2_access_key_id | No | Access key id of an R2 API token that can read and write that bucket. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. | |
| r2_secret_access_key | No | Its secret. Sealed in the job, deleted when it ends. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. |