当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript persistence.IBlobStorage类代码示例

本文整理汇总了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);
    }
开发者ID:paperbits,项目名称:paperbits-demo,代码行数:33,代码来源:pagePublisher.ts

示例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);
     }
 }
开发者ID:paperbits,项目名称:paperbits-demo,代码行数:9,代码来源:assetPublisher.ts

示例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);
        }
    }
开发者ID:paperbits,项目名称:paperbits-demo,代码行数:20,代码来源:mediaPublisher.ts

示例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");
 };
开发者ID:paperbits,项目名称:paperbits-demo,代码行数:4,代码来源:blogPublisher.ts


注:本文中的@paperbits/common/persistence.IBlobStorage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。