# Bulk File Downloader (Apify storage only) (`gramsesh/file-downloader`) Actor

Download files from URLs you supply into this run's Apify key-value store and list them in a dataset. v1 does not upload to S3. Hard cap 5 MB; oversize Content-Length is aborted before the body. Mid-fail or timed-out downloads are billed; instant 404s, blocks and skipped files are free.

- **URL**: https://apify.com/gramsesh/file-downloader.md
- **Developed by:** [Gramsesh](https://apify.com/gramsesh) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.90 / 1,000 files downloaded (up to 5 mb)

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bulk File Downloader (Apify storage only)

Download files from URLs you supply. Each successful file is stored in **this run's Apify key-value store** and listed in the dataset with its key, size, content type and SHA-256. **v1 does not upload to customer S3 or any other external destination.** There is no user code, no proxy rotation, and no helper for signing into a site.

Private, loopback, link-local and cloud-metadata addresses (including `169.254.169.254`) are blocked. The check runs before the request, again after DNS, and on every redirect. Connections are pinned to the already-checked IP. Social and streaming platform pages (YouTube, TikTok, Instagram, and similar) are rejected.

A successfully stored file (bytes > 0) is billed as `file-downloaded` (**$0.0019**). Downloads that fail partway or time out after work was done are billed the same way. Instant 404s, pre-send blocks and **skipped** files are **free**. There is no `transfer-megabyte` event; size is covered by a hard **5 MB** per-file cap. If `Content-Length` is over 5 MB, the download is aborted before the body and is not charged. If a stream passes 5 MB, it is aborted mid-download and is charged.

Files skipped because the run time cap, the total-byte cap, or the files-per-run cap was reached are listed in the dataset and in `SUMMARY.skippedFiles` / `SUMMARY.skippedUrls` so you can re-run those URLs in a new run. They are never charged.

Downloads are streamed to a temporary file so the body is not buffered in memory during the transfer. The Apify SDK's `set_value` still takes a bytes value, so the key-value write may load the file once; the 5 MB per-file cap keeps that within the 128 MB default memory.

### Input

- `urls`: list of http(s) URLs you have the right to download
- `concurrency`, `perHostRatePerSecond`, `timeoutSecs`, `maxRedirects`
- `maxFiles`, `maxFileSizeMb`, `maxTotalMb` (1 MB = 1,000,000 bytes)
- `allowedContentTypes` / `deniedContentTypes`
- `respectRobotsTxt` (default on)
- `filenamePrefix`

#### Caps (defaults / hard maxima a user cannot exceed)

| Cap | Default | Hard max |
|---|---:|---:|
| Files per run | 50 | 100 |
| Per-file size | 5 MB | 5 MB |
| Total bytes per run | 100 MB | 500 MB |
| Concurrency | 3 | 5 |
| Per-host rate | 1/s | 3/s |
| Timeout | 8 s | 10 s |
| Redirects | 5 | 10 |
| Run hang cap | 60 s | 60 s |

Default run memory is **128 MB** (minimum 128 MB, maximum 2,048 MB). The platform default timeout is **75 s**, a short buffer over the 60 s in-actor hang cap so results can be written.

### Robots and indexing

- **robots.txt** is fetched per host (SSRF-checked, not billed as a file). Disallowed paths are skipped. A missing or non-200 robots.txt is treated as allow, like ordinary crawlers. `Crawl-delay` is honored in addition to the per-host rate cap (the slower of the two applies).
- **X-Robots-Tag** values `none`, `noindex`, `noarchive` and `nosnippet` cause the file not to be stored.
- For HTML responses, a `<meta name="robots">` tag with `noindex` / `none` / `noarchive` in the first 8 KB also prevents storage.
- These checks exist so the Actor does not keep a copy of a resource the publisher asked crawlers not to archive. They are not a substitute for copyright permission.

### Where your output goes

Each stored file, the dataset row, and the run's `SUMMARY` are written only to **this run's default key-value store and dataset**, which belong to the Apify account that started the run. Nothing is copied to a Gramsesh account, to Cloudflare, or to any server of ours. v1 does not upload to customer S3 or any other external destination.

### Acceptable use

Do not use this Actor to download, store or distribute illegal content, including child sexual abuse material. We do not open customer runs except to answer an Issue you have asked us to look at. We report illegal content to Apify, and CSAM to NCMEC. Support: <chris@gramsesh.com>.

### Terms of use

You must have the right to download each file, and you must follow the site's terms and applicable law. Do not use this Actor to infringe copyright, to bypass a paywall, DRM, or authentication, or to scrape a site that forbids it. Do not point it at other people's content on social or streaming platforms. The platform may abuse-report or suspend accounts that do. Rate and size caps are enforced; they are not an invitation to run at the cap against a third-party site.

### Pricing

Pay per event.

- `file-downloaded`: **$0.0019** per successfully stored file, and for mid-fail or timed-out downloads after work was done. Instant 404s, pre-send blocks and skipped files are free. Hard file cap **5 MB**. There is no `transfer-megabyte` event.
- `apify-actor-start`: **$0.00050** per GB (minimum 1). A default 128 MB run is one start event (**$0.00050**).

A 1-file run at the default memory costs **$0.00240** listed. Instant 404s, pre-send blocks and skipped files are **free** (you still pay the start event). Platform usage is not passed through.

Empty and all-blocked runs do not write a `SUMMARY` file. Skipped files **are** listed in `SUMMARY` so you can re-run them. After the run, storage retention and downloads of your results are billed to the account that owns the run, not as part of these event prices.

#### Example input

```json
{
  "urls": ["https://example.com"]
}
```

### What this Actor does not do

- It does not upload to customer S3, GCS, Azure, or a webhook.
- It does not run code you supply or use residential proxies.
- It does not follow redirects onto private or metadata addresses.
- It does not bypass logins, paywalls or DRM.

# Actor input Schema

## `urls` (type: `array`):

Direct links to files you have the right to download (your own storage, a CDN, or a public-domain source). A small example.com page is prefilled for a trial run. Social and streaming platform pages are rejected.

## `filenamePrefix` (type: `string`):

Optional prefix for key-value store keys (for example 'batch1'). Keys look like 0001-filename.ext.

## `concurrency` (type: `integer`):

Maximum number of downloads in flight. Default 3, hard maximum 5.

## `perHostRatePerSecond` (type: `number`):

Maximum downloads per second to any one host. Default 1, hard maximum 3. robots.txt crawl-delay, if present, is also honored.

## `timeoutSecs` (type: `integer`):

Default 8, hard maximum 10. Enough for a 5 MB file on a slow link. The run also stops at a 60-second wall-clock hang cap.

## `maxRedirects` (type: `integer`):

Each hop is re-checked for SSRF. Default 5, hard maximum 10.

## `maxFiles` (type: `integer`):

Further URLs are skipped and are free. Default 50, hard maximum 100.

## `maxFileSizeMb` (type: `integer`):

Default and hard maximum 5 MB. Files with a Content-Length over the cap are aborted before the body.

## `maxTotalMb` (type: `integer`):

1 MB = 1,000,000 bytes. Further files are skipped once this budget is used. Default 100, hard maximum 500.

## `allowedContentTypes` (type: `array`):

Optional allow-list (for example image/png or image/\*). If set, any other type is rejected without being stored.

## `deniedContentTypes` (type: `array`):

Optional deny-list (for example text/html). Matching responses are not stored.

## `respectRobotsTxt` (type: `boolean`):

On by default. The Actor fetches /robots.txt for each host (SSRF-checked, not billed as a file) and skips disallowed paths. It also honors crawl-delay, X-Robots-Tag none/noindex/noarchive, and an HTML meta robots noindex when present in the first 8 KB. A missing robots.txt is treated as allow.

## Actor input object example

```json
{
  "urls": [
    "https://example.com"
  ],
  "concurrency": 3,
  "perHostRatePerSecond": 1,
  "timeoutSecs": 8,
  "maxRedirects": 5,
  "maxFiles": 50,
  "maxFileSizeMb": 5,
  "maxTotalMb": 100,
  "respectRobotsTxt": true
}
```

# Actor output Schema

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gramsesh/file-downloader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://example.com"] }

# Run the Actor and wait for it to finish
run = client.actor("gramsesh/file-downloader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://example.com"
  ]
}' |
apify call gramsesh/file-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gramsesh/file-downloader"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CfBqqef4GrFTYWnyr/builds/QMsVYUws0lni0F8QE/openapi.json
