Handles file uploads for QR code images such as logos and backgrounds.
curl -X POST \
'https://apis.divsly.com/api/v1/qr-code/file-upload' \
-H 'Authorization: Bearer YOUR_JWT_TOKEN_HERE' \
-F 'file=@logo.png'
const uploadQrImage = (file) => {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append('file', file);
fetch('https://apis.divsly.com/api/v1/qr-code/file-upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
},
body: formData
})
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error));
});
};
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const uploadQrImage = (filePath) => {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append('file', fs.createReadStream(filePath));
axios({
method: 'post',
url: 'https://apis.divsly.com/api/v1/qr-code/file-upload',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
...formData.getHeaders()
},
data: formData
})
.then(response => resolve(response.data))
.catch(error => reject(error.response.data));
});
};
$data = array(
'file' => new CURLFile('logo.png')
);
$ch = curl_init('https://apis.divsly.com/api/v1/qr-code/file-upload');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer YOUR_JWT_TOKEN_HERE'
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
import requests
url = 'https://apis.divsly.com/api/v1/qr-code/file-upload'
headers = {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
try:
with open('logo.png', 'rb') as file_handle:
response = requests.post(
url,
headers=headers,
files={'file': file_handle}
)
response.raise_for_status()
print(response.json())
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
{
"message": "File uploaded successfully",
"url": "https://s3.amazonaws.com/bucket/qr-preview/1712044800000-logo.png",
"fileName": "logo.png",
"size": 15234,
"mimetype": "image/png"
}
{
"message": "Invalid file type or missing file"
}
{
"message": "Unauthorized!"
}
{ "message": "Method not allowed" }