首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Web应用程序中存储PDF文件

如何在Web应用程序中存储PDF文件
EN

Stack Overflow用户
提问于 2021-11-20 10:03:16
回答 1查看 83关注 0票数 2

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

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

什么是Azure Cosmos DB?它对我们的高性能和可伸缩性是有好处的,还是Azure中有一些最好的东西可以满足我们的需求。

EN

回答 1

Stack Overflow用户

发布于 2021-11-20 11:05:24

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

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

代码语言:javascript
复制
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;
    }

使用SQL API

  1. Azure Cosmos DB触发器、输入绑定和输出绑定

你可以参考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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70044918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档