當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。