You can download files from this route
You can upload files using this route. Example:
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const apiUrl = 'https://api.discreetshare.com/upload';
const filePath = './your-file';
const fileStream = fs.createReadStream(filePath);
let fileSize;
fileStream.on('data', (chunk) => {
fileSize = chunk.length;
});
fileStream.on('end', () => {
const formData = new FormData();
formData.append('file', fileStream, { knownLength: fileSize });
axios.post(apiUrl, formData, {
headers: {
...formData.getHeaders(),
'Content-Length': fileSize,
},
})
.then((response) => {
console.log('File uploaded successfully:', response.data);
})
.catch((error) => {
console.error('Error uploading file:', error);
});
});
Use this route to stream images by file ID. The server will verify the file type and stream it back if it's an image, functioning like a simple CDN. Heads Up: Please note that our GIF streaming feature might not be fully supported on all platforms, leading to GIFs appearing as static images in some cases.