export all my image URL with Item ID

  1. Add the full file names to your csv file (make sure each file has a unique name).

  2. Import the csv to your collection.

  3. Create a webpage and add an upload button.

  4. Use code to upload multi-files.

  5. Once the files are loaded, query the collection for their original name.

  6. Update the URL.
    Something like:

import wixData from 'wix-data';
let fileData = [];
$w.onReady(() => {
  $w('#uploadAllBtn').onClick( () => {
    if($w('#uploadButton').value.length < 1) { return;}             
    $w('#uploadButton').uploadFiles()
    .then(files => {
      fileData = files;
      const fNames = files.map(f => f.originalFileName);
      return wixData.query('CollectionName').hasSome('fileName', fNames).limit(1000).find()
    })
    .then(r => {
      const {items} = r;
      if(!items.length){return Promise.reject('query failed');}
  	items.forEach(e => {
	  const file = fileData.find(f => f.originalFileName === e.fileName);
	  if(file){
		e.imageUrl  = file.fileUrl;
        }
      })
      return wixData.bulkUpdate('CollectionName', items);
    })
  .then(() => console.log('DONE'))
  .catch(err => console.error(err));
  });
})
1 Like