# DIGITAL PRODUCT IMPLEMENTATION PLAN

## Overview
Implementation plan for the Digital Product download and upload system for the `apwp-pc` (Products & Cart) plugin.

## Technical Details
- **SKU:** `apwp-pc`
- **Middleware Group:** `['auth.plugin', 'check.plugin.purchase:apwp-pc']`
- **Storage Disk:** `s3`
- **Storage Path Pattern:** `{userId}/downloads/{filename}`

## Endpoints

### 1. File Upload
- **Route:** `POST /api/plugin/product-upload`
- **Controller Method:** `S3ProductDownloadController@upload`
- **Payload (multipart/form-data):**
  - `file`: Binary file content.
  - `filename`: String (e.g., `digital_product.zip`).
- **Response Object:**
  ```json
  {
      "success": true,
      "path": "123/downloads/digital_product.zip",
      "url": "https://bucket.s3.region.amazonaws.com/123/downloads/digital_product.zip"
  }
  ```

### 2. Retrieve Signed Download Link
- **Route:** `GET /api/plugin/product-download-link`
- **Controller Method:** `S3ProductDownloadController@getDownloadLink`
- **Payload (Query String):**
  - `filename`: String (the filename stored in the user's downloads folder).
  - `expires_in`: Integer (minutes for link expiration).
- **Response Object:**
  ```json
  {
      "success": true,
      "url": "https://bucket.s3.region.amazonaws.com/123/downloads/digital_product.zip?X-Amz-Signature=...",
      "expires_in_minutes": 15
  }
  ```

## Implementation Steps
1. **Create Controller:** Define `App\Http\Controllers\S3ProductDownloadController` to handle S3 interactions.
2. **Register Routes:** Add the new routes to `routes/plugin.php` using the established middleware pattern.
3. **Validation:** Ensure files are restricted to the `{userId}/downloads/` prefix to prevent unauthorized access to other user data.
