Netlify Large Media integration (#2124)

This commit is contained in:
Benaiah Mischenko
2019-02-26 10:11:15 -08:00
committed by Shawn Erquhart
parent 17ae6f3045
commit da2249c651
18 changed files with 491 additions and 92 deletions

View File

@ -147,7 +147,7 @@ export default class GitLab {
return this.api.listAllFiles(this.config.get('media_folder')).then(files =>
files.map(({ id, name, path }) => {
const getBlobPromise = () =>
const getDisplayURL = () =>
new Promise((resolve, reject) =>
sem.take(() =>
this.api
@ -159,12 +159,13 @@ export default class GitLab {
}
return blob;
})
.then(blob => URL.createObjectURL(blob))
.then(resolve, reject)
.finally(() => sem.leave()),
),
);
return { id, name, getBlobPromise, path };
return { id, name, getDisplayURL, path };
}),
);
}
@ -176,8 +177,7 @@ export default class GitLab {
async persistMedia(mediaFile, options = {}) {
await this.api.persistFiles([mediaFile], options);
const { value, path, fileObj } = mediaFile;
const getBlobPromise = () => Promise.resolve(fileObj);
return { name: value, size: fileObj.size, getBlobPromise, path: trimStart(path, '/') };
return { name: value, size: fileObj.size, path: trimStart(path, '/') };
}
deleteFile(path, commitMessage, options) {