【问题标题】:How to Store PDF Files in Web Application如何在 Web 应用程序中存储 PDF 文件
【发布时间】:2021-11-20 20:17:14
【问题描述】:

我们的网站是一个机票预订系统,现在我们希望在用户仪表板面板中显示用户预订的所有机票,他们可以在其中下载特定预订日期的 PDF 格式的机票。

我们需要一个建议——将所有 pdf 文件存储在哪里是最佳选择。我们的 Web 应用程序是一个 Azure 网站,并将所有信息存储在 SQL 数据库中。

什么是 Azure Cosmos DB?它是否对我们有利于实现高性能和可扩展性目的,或者 Azure 中是否有最适合我们要求的东西。

【问题讨论】:

    标签: azure azure-web-app-service


    【解决方案1】:

    您可以使用以下两种方式将 PDF 文件存储在 Web 应用程序中:

    1。您可以将 PDF 上传到 blob 存储,然后将 cosmosdb 的引用保存为 URI,如 Sajeetharan 所回答的那样

    private async Task<Guid> UploadDocument(Uri uri, string imageName)
        {
    
            var endpoint = new Uri(_settings.ImageConfig.CosmosUri);
            var auth = _settings.ImageConfig.CosmosKey;
            var client = new DocumentClient(endpoint, auth);
            var identifier = Guid.NewGuid();
    
            await client.CreateDatabaseIfNotExistsAsync(new Database() { Id = dbName });
            await client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(dbName),
                new DocumentCollection { Id = colName });
    
            await client.CreateDocumentAsync(
                UriFactory.CreateDocumentCollectionUri(dbName, colName),
                new ImageDocument
                {
                    Id = identifier,
                    IsApproved = null,
                    PetName = petName,
                    MediaUrl = uri.ToString(),
                    Created = DateTime.UtcNow
                });
    
            return identifier;
        }
    
    1. Azure Cosmos DB 触发器、输入绑定和输出绑定使用 SQL API

    您可以参考How upload file to blob storage and reference it from cosmosdb document in attachmentAzure DocumentDB vs Blob Storage for multiple PDF files per userStore unstructured data using Azure Functions and Azure Cosmos DBHow to effectively use CosmosDB as Document storage

    【讨论】:

    • 我们希望在 CMOS 数据库中存储每个用户明智的大 JSON 的工单响应,并且在运行时下载工单时会将 json 转换为 PDF,您认为这是正确的方法吗?
    • 我知道有一些方法,但考虑到high performance and scalability purposes,我不是对此发表评论的专家
    • 您可以通过raise support ticketTwitter @AzureSupport 与Microsoft 联系,也可以在Microsoft Q&A 上提出相同的问题
    猜你喜欢
    • 2014-07-06
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 2011-02-27
    相关资源
    最近更新 更多