Skip to content

Instantly share code, notes, and snippets.

@optlsnd
Created July 18, 2023 06:21
Show Gist options
  • Save optlsnd/7a800e95afe57f87f13cfe798513e3c3 to your computer and use it in GitHub Desktop.
Save optlsnd/7a800e95afe57f87f13cfe798513e3c3 to your computer and use it in GitHub Desktop.
import {
listOfFiles,
UploadcareSimpleAuthSchema,
paginate,
} from "@uploadcare/rest-client";
const uploadcareSimpleAuthSchema = new UploadcareSimpleAuthSchema({
publicKey: process.env.UC_PUBLIC_KEY,
secretKey: process.env.UC_SECRET_KEY,
});
const paginatedListOfFiles = paginate(listOfFiles);
const pages = paginatedListOfFiles(
{ removed: false, limit: 1000 },
{ authSchema: uploadcareSimpleAuthSchema }
);
// List files and filter out videos with `variations` metadata
for await (const page of pages) {
page.results.forEach((file) => {
if (file.mimeType.indexOf("video") > -1 && file.variations !== null) {
console.log(file.uuid);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment