# Share an object with a presigned URL

Give someone time-limited access to one object without a key, with a presigned URL.

A presigned URL grants access to one object until it expires. Replace _example-uploads_ with your
bucket's name and _report.pdf_ with the object's key.

## Prerequisites

- Permission for `s3:GetObject` on the object (`s3:GetObjectVersion` for an older version), or
  `s3:PutObject` for an upload URL. The URL can do no more than the key or user that signs it.

## Create the URL

**Console:** not available. The console's **Download** uses such a URL for you but does not show it.
**CLI**
```sh
dcloud s3 bucket-objects download-url example-uploads --key report.pdf
```

**API**
```http
POST /s3/api/buckets/example-uploads/objects/download-url
{ "key": "report.pdf" }
```

The answer is `{ url, expiresInSeconds }`: a URL valid for 900 seconds (15 minutes) that downloads
the object. `upload-url` (`s3:PutObject`) answers a URL to `PUT` one object, with the
`Content-Type` header it must carry, also valid 15 minutes.

With an S3 client you choose the lifetime, up to 7 days (604800 seconds):

```sh
aws --profile dcloud s3 presign s3://example-uploads/report.pdf --expires-in 3600
```

## Result

The URL works until it expires, then answers `AccessDenied` "Request has expired". A URL you
presigned with an S3 client stops working at once when you delete the access key that signed it.
The URL from `download-url` makes the browser save the object as a file. A browser on another site that loads the URL from a script
needs a CORS rule on the bucket (see
[Let a web page use the bucket](configure-cors.md)).

## Related

- [Upload and download objects](upload-and-download-objects.md)
- `s3.bucket-objects.download-url` · `dcloud s3 bucket-objects download-url`
