Dalibor Votruba 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
..
admin 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
assets 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
languages 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
directory-structure.txt 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
instructions.txt 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
qdr-temporary-shared-storage.php 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
readme.md 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu
readme.txt 4ee6acfe98 qdr-temporary-shared-storage: add initial version 1.0.0 1 rok temu

readme.md

QDR - Temporary Shared Storage (via REST API)

Version: 1.0.0

A WordPress plugin that extends functionality for REST API interface to upload temporary media files and provide permalink to password-protected download pages.

Description

QDR Temporary Shared Storage enables secure sharing of large files through WordPress with complete control over access and expiration. This plugin is ideal for businesses that need to share sensitive documents, large media files, or private content with clients or team members for a limited time.

Requirements

  • WordPress 6.8.1 or higher
  • PHP 8.2 or higher
  • WooCommerce 9.0 or higher (if WooCommerce integration is used)

Features

  • REST API Integration: Upload and manage files programmatically
  • Chunked File Uploads: Support for uploading large files in chunks
  • Password Protection: Secure access to shared files
  • Automatic Expiration: Files automatically expire and are removed after their expiration date
  • Download Tracking: Track number of downloads and last download time
  • Admin Interface: Manage shared files through a user-friendly admin interface
  • Custom Reference Codes: Add reference codes for additional verification
  • Storage Management: Set limits on total storage used by shared files
  • WordPress Media Library Integration: Files are properly registered in WordPress media system

Installation

  1. Upload the qdr-temporary-shared-storage directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Configure the plugin settings in 'Settings > Shared Storage'

Usage

Admin Interface

  • Media > Shared Storage: Manage all shared files
  • Settings > Shared Storage: Configure plugin settings

REST API Endpoints

All REST API requests require an API key sent in the X-Api-Key header.

Upload Files (Chunked)

  1. Initialize upload:

    POST /wp-json/qdr-tss/v1/upload/init
    

    Parameters:

  2. original_file_name: Original file name

  3. file_size: File size in bytes

  4. Upload chunks:

    POST /wp-json/qdr-tss/v1/upload/chunk
    

    Parameters:

  5. upload_id: Upload ID from initialization

  6. chunk_index: Index of the current chunk

  7. total_chunks: Total number of chunks

  8. chunk: File data (multipart/form-data)

  9. Finalize upload:

    POST /wp-json/qdr-tss/v1/upload/finalize
    

    Parameters:

  10. upload_id: Upload ID from initialization

  11. total_chunks: Total number of chunks

  12. original_file_name: Original file name

  13. description: File description

  14. message: Custom message (optional)

  15. active_from: Date from which permalink will be active (optional)

  16. active_to: Date until which permalink will be active (optional)

  17. password: Password for download protection

  18. reference: Custom reference value (optional)

Manage Files

  • Get file details:

    GET /wp-json/qdr-tss/v1/media/{id}
    
  • Update file properties:

    PUT /wp-json/qdr-tss/v1/media/{id}
    

    Parameters:

  • message: Custom message (optional)

  • active_from: Date from which permalink will be active (optional)

  • active_to: Date until which permalink will be active (optional)

  • reference: Custom reference value (optional)

  • description: File description (optional)

  • Delete file:

    DELETE /wp-json/qdr-tss/v1/media/{id}
    
  • Get collection of files:

    GET /wp-json/qdr-tss/v1/media
    

    Parameters:

  • page: Page number (optional, default: 1)

  • per_page: Items per page (optional, default: 10)

  • orderby: Field to sort by (optional)

  • order: Sort order, ASC or DESC (optional)

  • original_file_name: Filter by file name (optional)

  • reference: Filter by reference (optional)

Shortcode

To display a download form for a specific file:

[qdr_tss_download id="123"]

To display a generic download form where users can enter an ID, password, and reference:

[qdr_tss_download]

Configuration Options

API Key

Generate or specify an API key for REST API authentication.

Media Category

Specify a category to assign to uploaded media files.

Maximum Storage Size

Set the maximum total storage size for all shared files.

Example API Usage (PHP)

// Initialize upload
$ch = curl_init('https://www.quadarax.com/wp-json/qdr-tss/v1/upload/init');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Api-Key: your-api-key-here'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'original_file_name' => 'example.pdf',
    'file_size' => filesize('path/to/example.pdf')
]);
$response = json_decode(curl_exec($ch));
curl_close($ch);

$upload_id = $response->upload_id;

// Upload chunks
$file = fopen('path/to/example.pdf', 'rb');
$chunk_size = 1024 * 1024; // 1MB chunks
$total_size = filesize('path/to/example.pdf');
$total_chunks = ceil($total_size / $chunk_size);

for ($i = 0; $i < $total_chunks; $i++) {
    $chunk_data = fread($file, $chunk_size);
    
    $ch = curl_init('https://www.quadarax.com/wp-json/qdr-tss/v1/upload/chunk');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'X-Api-Key: your-api-key-here'
    ]);
    
    $post_data = [
        'upload_id' => $upload_id,
        'chunk_index' => $i,
        'total_chunks' => $total_chunks,
        'chunk' => new CURLFile('php://temp', 'application/octet-stream', 'chunk')
    ];
    
    // Write chunk data to temp file
    $temp = fopen('php://temp', 'wb+');
    fwrite($temp, $chunk_data);
    rewind($temp);
    
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $response = json_decode(curl_exec($ch));
    curl_close($ch);
    
    fclose($temp);
}

fclose($file);

// Finalize upload
$ch = curl_init('https://www.quadarax.com/wp-json/qdr-tss/v1/upload/finalize');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Api-Key: your-api-key-here'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'upload_id' => $upload_id,
    'total_chunks' => $total_chunks,
    'original_file_name' => 'example.pdf',
    'description' => 'Example PDF file',
    'message' => 'Please review this document',
    'password' => 'secure_password',
    'reference' => 'REF123',
    'active_to' => date('Y-m-d H:i:s', strtotime('+30 days'))
]);
$response = json_decode(curl_exec($ch));
curl_close($ch);

// Get download link and media ID
$media_id = $response->media_id;
$permalink = $response->permalink;

Security Considerations

  • All shared files are password-protected
  • Files are stored in a protected directory that cannot be accessed directly
  • Automatic expiration prevents unauthorized access to outdated files
  • API authentication through an API key ensures only authorized applications can upload files

License

GPL v2 or later - https://www.gnu.org/licenses/gpl-2.0.html

Author

Dalibor Votruba

Support

For support or feature requests, please visit QDR Plugin Page.