Created
June 5, 2019 10:58
-
-
Save optlsnd/17cf31200742906a9a29d389c450b2e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios') // needs to be installed with "npm i axios --save" | |
const PUBLIC_KEY = 'your_public_key_here' | |
const SECRET_KEY = 'your_secret_key_here' | |
const endpoint = 'https://api.uploadcare.com/files/?limit=1000&removed=false' | |
const config = { | |
headers: { | |
"Authorization": `Uploadcare.Simple ${PUBLIC_KEY}:${SECRET_KEY}` | |
} | |
} | |
const files = [] | |
function getData(url) { | |
axios.get(url, config).then(res => { | |
files.push(...res.data.results) | |
console.log(`${files.length} of ${res.data.total}`) | |
if (res.data.next !== null) { | |
getData(res.data.next) | |
} else { | |
files.forEach(file => { | |
if (file.original_filename.indexOf('15314') !== -1) { // replace 14314 with your query string | |
console.log(file.uuid) | |
} | |
}) | |
} | |
}) | |
} | |
getData(endpoint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment