我们的网站是一个机票预订系统,现在我们想要在一个用户仪表板面板中显示用户预订的所有机票,在那里他们可以下载PDF格式的机票为一个特定的预订日期。
我们需要一个建议--它将是存储所有pdf文件的最佳选择。我们的web应用程序是Azure网站,并将所有信息存储在SQL数据库中。
什么是Azure Cosmos DB?它对我们的高性能和可伸缩性是有好处的,还是Azure中有一些最好的东西可以满足我们的需求。
发布于 2021-11-20 11:05:24
您可以使用以下两种方法在web应用程序中存储PDF文件:
1。您可以将PDF上传到blob存储,然后将对cosmosdb的引用保存为Sajeetharan回答的URI
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的
你可以参考How upload file to blob storage and reference it from cosmosdb document in attachment,Azure DocumentDB vs Blob Storage for multiple PDF files per user,Store unstructured data using Azure Functions and Azure Cosmos DB和How to effectively use CosmosDB as Document storage
https://stackoverflow.com/questions/70044918
复制相似问题