|
|
1 سال پیش | |
|---|---|---|
| .. | ||
| admin | 1 سال پیش | |
| assets | 1 سال پیش | |
| languages | 1 سال پیش | |
| directory-structure.txt | 1 سال پیش | |
| instructions.txt | 1 سال پیش | |
| qdr-temporary-shared-storage.php | 1 سال پیش | |
| readme.md | 1 سال پیش | |
| readme.txt | 1 سال پیش | |
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.
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.
qdr-temporary-shared-storage directory to the /wp-content/plugins/ directoryAll REST API requests require an API key sent in the X-Api-Key header.
Initialize upload:
POST /wp-json/qdr-tss/v1/upload/init
Parameters:
original_file_name: Original file name
file_size: File size in bytes
Upload chunks:
POST /wp-json/qdr-tss/v1/upload/chunk
Parameters:
upload_id: Upload ID from initialization
chunk_index: Index of the current chunk
total_chunks: Total number of chunks
chunk: File data (multipart/form-data)
Finalize upload:
POST /wp-json/qdr-tss/v1/upload/finalize
Parameters:
upload_id: Upload ID from initialization
total_chunks: Total number of chunks
original_file_name: Original file name
description: File description
message: Custom message (optional)
active_from: Date from which permalink will be active (optional)
active_to: Date until which permalink will be active (optional)
password: Password for download protection
reference: Custom reference value (optional)
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)
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]
Generate or specify an API key for REST API authentication.
Specify a category to assign to uploaded media files.
Set the maximum total storage size for all shared files.
// 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;
GPL v2 or later - https://www.gnu.org/licenses/gpl-2.0.html
For support or feature requests, please visit QDR Plugin Page.