本文整理匯總了TypeScript中@paperbits/common/persistence.IBlobStorage類的典型用法代碼示例。如果您正苦於以下問題:TypeScript IBlobStorage類的具體用法?TypeScript IBlobStorage怎麽用?TypeScript IBlobStorage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IBlobStorage類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: publish
public async publish(): Promise<void> {
const pages = await this.pageService.search("");
const results = [];
const settings = await this.siteService.getSiteSettings();
let iconFile;
if (settings && settings.site.faviconSourceKey) {
iconFile = await this.mediaService.getMediaByKey(settings.site.faviconSourceKey);
}
let imageFile;
if (settings && settings.site.ogImageSourceKey) {
imageFile = await this.mediaService.getMediaByKey(settings.site.ogImageSourceKey);
}
// const renderAndUpload = async (page): Promise<void> => {
// const pageRenderResult = await this.renderPage(page, settings, iconFile, imageFile);
// await this.outputBlobStorage.uploadBlob(pageRenderResult.name, pageRenderResult.bytes);
// };
// for (const page of pages) {
// results.push(renderAndUpload(page));
// }
for (const page of pages) {
const pageRenderResult = await this.renderPage(page, settings, iconFile, imageFile);
results.push(this.outputBlobStorage.uploadBlob(pageRenderResult.permalink, pageRenderResult.bytes, "text/html"));
}
await Promise.all(results);
}
示例2: copyAssetFrom
private async copyAssetFrom(assetPath: string): Promise<void> {
try {
const byteArray = await this.downloadBlob(assetPath);
await this.outputBlobStorage.uploadBlob(assetPath, byteArray);
}
catch (error) {
console.log(assetPath + " assets error:" + error);
}
}
示例3: renderMediaFile
private async renderMediaFile(mediaFile: MediaContract): Promise<void> {
try {
if (mediaFile.blobKey) {
const blob = await this.blobStorage.downloadBlob(mediaFile.blobKey);
if (blob) {
await this.outputBlobStorage.uploadBlob(mediaFile.permalink, blob, mediaFile.mimeType);
return;
}
}
if (mediaFile.downloadUrl) { // if blob doesn't exit check if direct download URL is specifed:
const response = await this.httpClient.send({ url: mediaFile.downloadUrl });
await this.outputBlobStorage.uploadBlob(mediaFile.permalink, response.toByteArray(), mediaFile.mimeType);
}
}
catch (error) {
console.warn(error);
}
}
示例4: async
const renderAndUpload = async (page): Promise<void> => {
const pageRenderResult = await this.renderBlogPost(page, settings, iconFile);
await this.outputBlobStorage.uploadBlob(pageRenderResult.name, pageRenderResult.bytes, "text/html");
};