When we stream or request these URLs concurrently in bulk on our platform, they occasionally return HTML content instead of the expected image buffer. With the new content-type verification feature we introduced for files to be uploaded, the validation fails when Dropbox returns HTML instead of an image or binary file. This causes uploads to succeed intermittently.
const axios = require("axios"); // Define the cURL equivalent request const makeRequest = async () => { try { const urls = [ "https://www.dropbox.com/scl/fo/v3yos9i0yfi0rhz5d71fg/AA-x7YlVr36dRcIyKnmC-eA/X3VI09KBZ13VRR_1.jpg?rlkey=2eqhcmouhjb20eo364j6t9o5e&e=1&dl=1", "https://www.dropbox.com/scl/fo/v3yos9i0yfi0rhz5d71fg/AKRLiS-6DE2QicEIY-P7wCY/X3VI09KBZ13VRR_2.jpg?rlkey=2eqhcmouhjb20eo364j6t9o5e&e=1&dl=1", "https://www.dropbox.com/scl/fo/v3yos9i0yfi0rhz5d71fg/AA-x7YlVr36dRcIyKnmC-eA/X3VI09KBZ13VRR_1.jpg?rlkey=2eqhcmouhjb20eo364j6t9o5e&e=1&dl=1", "https://www.dropbox.com/scl/fo/v3yos9i0yfi0rhz5d71fg/AKRLiS-6DE2QicEIY-P7wCY/X3VI09KBZ13VRR_2.jpg?rlkey=2eqhcmouhjb20eo364j6t9o5e&e=1&dl=1", ]; const urlRequestPromise = urls.map(url => axios.get(url, { maxRedirects: 5, timeout:10000 })); const responses = await Promise.all(urlRequestPromise); responses.map(response => { console.log("Content Type - ", response.headers["content-type"]); }); } catch (error) { console.error("Error making request:", error); } }; // Create an array of promises to execute the request 100 times const requests = Array.from({ length: 10 }, () => makeRequest()); // Execute all requests in parallel Promise.all(requests) .then(() => { console.log("All requests completed"); }) .catch((error) => { console.error("Error with requests:", error); });