本文整理汇总了TypeScript中@paperbits/common/persistence.IBlobStorage.uploadBlob方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IBlobStorage.uploadBlob方法的具体用法?TypeScript IBlobStorage.uploadBlob怎么用?TypeScript IBlobStorage.uploadBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@paperbits/common/persistence.IBlobStorage
的用法示例。
在下文中一共展示了IBlobStorage.uploadBlob方法的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");
};