Upload files from URLs

POST

Uploadcare can fetch a file from a publicly available URL and then automatically upload the fetched file to your project.

Upload tokens

Requests to the endpoint return a JSON dictionary with a token that can be further used to check the status of the upload request.

Note: The token is not a file ID and can’t be used to address the file directly. The actual file ID should be retrieved by calling the /from_url/status/ endpoint.

Duplicates prevention

By default, every call to the /from_url/ endpoint with the same source_url results in a new upload leading to file duplication.

If you would like Uploadcare to keep track of the requested URLs and avoid the duplicate uploads, pass the save_URL_duplicates and check_URL_duplicates parameters described below.

Request

This endpoint expects a multipart form.
pub_keystringRequired
Public key identifying an Uploadcare project your uploads will go to.
source_urlstringRequired

Source URL of the file to fetch and upload.

Note: The URL should point to a resource publicly available via HTTP/HTTPS.

storeenumOptionalDefaults to auto

Determines if an uploaded file should be marked as temporary or permanent.

The parameter can have the following values:

  • 0 - do not mark an uploaded file as stored and remove it after 24 hours
  • 1 - mark the uploaded file as stored
  • auto - delegate the choice of the file-storing behavior to a project-wide setting called auto-store.

The default value depends on the user registration date.

For all users registered after February 12, 2024 (UTC 13:30), the default value is auto. File-storing behavior depends entirely on what is set in the storage settings in the Dashboard.

For users registered before February 12, 2024, the default value is 0. To ensure that file storage in the project matches the settings in the Dashboard, change the value to auto.

Allowed values: 01auto
filenamestringOptional

Sets the file name of the resource fetched from the source URL. If not defined, the file name is obtained from either HTTP response headers or the source_url’s path.

Note: The filename will be sanitized to only contain the following symbols: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._.

check_URL_duplicates"0" or "1"OptionalDefaults to 0

If set to “1”, enables the source_url duplicates prevention. Specifically, if the source_url had already been fetched and uploaded previously, this request will return information about the already uploaded file.

Allowed values: 01
save_URL_duplicates"0" or "1"Optional

Determines if the requested source_url should be kept in the history of fetched/uploaded URLs. If the value is not defined explicitly, it is set to the value of the check_URL_duplicates parameter.

Allowed values: 01
metadata[{key}]stringOptional

Arbitrary metadata associated with the file. See docs and REST API for more information.

signaturestringOptional

signature must be sent along with your upload request if you would like to use signed uploads. The signature should be generated on your backend. Note: the process requires knowledge of your Uploadcare Project’s Secret key. See signed uploads for details.

expiredoubleOptional

expire must be sent along with your upload request if you would like to use signed uploads. The parameter defines the time during which your signature is valid. It’s a UNIX timestamp. See signed uploads for details.

Response

This endpoint returns an object.
From URL Upload Response Schemaobject
OR
File Upload Info from URLobject

Errors