> For the complete documentation index, see [llms.txt](https://clients.medianova.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clients.medianova.com/products/object-storage-stook/integration-and-usage-guides/how-to-use-pre-signed-url-in-php-with-stook.md).

# How to Use Pre-Signed URL in PHP with Stook

Generate and use pre-signed URLs in PHP for accessing objects in Medianova Stook Object Storage.

You can generate **pre-signed URLs** with the **AWS SDK for PHP** to securely access or share objects stored in **Medianova Stook Object Storage**. Pre-signed URLs allow time-limited access without exposing your credentials.

***

### Prerequisites

* PHP installed on your system
* AWS SDK for PHP included in your project
* Medianova Stook credentials (Access Key, Secret Key, Endpoint)

***

### Example: Generate a Pre-Signed URL

```php
require 'vendor/autoload.php';

use Aws\S3\S3Client;  
use Aws\S3\Exception\S3Exception;

$bucket = "bucket";  
$key = "mykey";  

// Create a S3Client  
$s3 = new Aws\S3\S3Client([
    'endpoint' => 'https://customername.mncdn.com',
    'profile' => 'medianova',
    'version' => 'latest',
    'region' => 'us-east-1',
    'use_path_style_endpoint' => true
]);

$cmd = $s3->getCommand('GetObject', [
    'Bucket' => $bucket,
    'Key'    => $key,
]);

$request = $s3->createPresignedRequest($cmd, '+20 minutes');  

$presignedUrl = (string) $request->getUri();  
echo $presignedUrl;
```

***

### How It Works

1. Define your **bucket** and **object key**.
2. Create an **S3Client** with your Stook endpoint and credentials.
3. Use the `getCommand` method to specify the operation (e.g., `GetObject`).
4. Generate a pre-signed URL with `createPresignedRequest`.
5. Share or use the generated URL to access the object for a limited time.

***

### Troubleshooting / FAQ

* **Expired URL:** Check the validity time (`+20 minutes`, `+1 hour`, etc.).
* **Access denied:** Verify bucket policy and Stook credentials.
* **Invalid endpoint:** Ensure your Stook endpoint matches your account.

***

### References

* [AWS SDK for PHP Documentation](https://docs.aws.amazon.com/aws-sdk-php/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://clients.medianova.com/products/object-storage-stook/integration-and-usage-guides/how-to-use-pre-signed-url-in-php-with-stook.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
