Logo
⌘K

Uploads

Images that you upload to Artelo are represented by Upload objects.

Bulk Uploads

Our general guideline for uploading a large number of files is to upload multiple files in parallel and poll the API until all files have finished uploading.

// Start uploading each image in parallel
await Promise.all(
   images.map(async (image) =>
     fetch('https://www.artelo.io/api/open/uploads/create', {
       method: 'POST',
       headers: {
         'Content-Type': 'application/json',
         Authorization: 'Bearer ...'
       },
       body: JSON.stringify({
         imageUrl: image.url,
         name: image.filename
       })
     })
   )
 );

 // Poll the number of pending uploads until all are no longer pending
 let pendingCount = 0;
 do {
   // Wait five seconds before checking again
   await new Promise((r) => setTimeout(r, 5000));

   const response = await fetch('https://www.artelo.io/api/open/uploads/get-counts-by-status', {
     method: 'GET',
     headers: { Authorization: 'Bearer ...' }
   });
   const uploadCounts = await response.json();

   pendingCount = uploadCounts.Pending;
 } while (pendingCount > 0);
Example of how to poll for completed uploads.