Uploading a file to Pacem Storage is easy: just stream your data to our REST API.
Here's how you can do it in different programming languages or script tools:
curl -X POST \ -H "X-Api-access-key-id: YOUR_WRITE_ONLY_ACCESS_KEY_ID" \ -H "X-Api-secret-access-key: YOUR_WRITE_ONLY_SECRET_KEY" \ -H "X-file-name: A_NAME_FOR_THE_UPLOADED_FILE" \ -H "Content-Type: application/octet-stream" \ -T YOUR_LOCAL_FILE \ https://api.pacemstorage.com/api/upload
wget --method=POST \ --header="X-Api-access-key-id: YOUR_WRITE_ONLY_ACCESS_KEY_ID" \ --header="X-Api-secret-access-key: YOUR_WRITE_ONLY_SECRET_KEY" \ --header="X-file-name: A_NAME_FOR_THE_UPLOADED_FILE" \ --header="Content-Type: application/octet-stream" \ --body-file=YOUR_LOCAL_FILE \ -O - \ --quiet \ https://api.pacemstorage.com/api/upload
const axios = require('axios');
const fs = require('fs');
axios
.post(
'https://api.pacemstorage.com/api/upload',
fs.createReadStream(YOUR_LOCAL_FILE), {
headers: {
'X-Api-access-key-id': YOUR_WRITE_ONLY_ACCESS_KEY_ID,
'X-Api-secret-access-key': YOUR_WRITE_ONLY_SECRET_KEY,
'X-file-name': A_NAME_FOR_THE_UPLOADED_FILE,
'Content-Type': 'application/octet-stream',
},
})
.then((response) => {
console.log('File uploaded successfully:', response.data);
})
.catch((error) => {
console.error('Error uploading file:', error);
});
<?php
$filePath = YOUR_LOCAL_FILE;
$handle = fopen($filePath, 'r');
$ch = curl_init('https://api.pacemstorage.localhost:3000/api/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-access-key-id: YOUR_WRITE_ONLY_ACCESS_KEY_ID',
'X-Api-secret-access-key: YOUR_WRITE_ONLY_SECRET_KEY',
'X-file-name: A_NAME_FOR_THE_UPLOADED_FILE',
'Content-Type: application/octet-stream'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $handle);
curl_setopt($ch, CURLOPT_INFILE, $handle);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filePath));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo 'Response:' . $response;
}
curl_close($ch);
fclose($handle);