【发布时间】:2015-01-04 10:17:16
【问题描述】:
我正在将图像上传到 documentDb。我将文件名分配给 slug 属性。我使用上传期间获得的media link 检索附件。
我的期望是,当我检索附件时,我会找回我的文件名。但相反,Azure 将 slug 返回为 null。我已经仔细检查了检索到的附件的内容是否正确。
两个问题:
- 我是否滥用了
slug属性? - 我应该在哪里分配自定义属性?
这是我的代码:
public async Task<string> UploadAttachment(string selfLinkId, Stream mediaStream, string contentType, string fileName)
{
Document foundDocument = (await _client.ReadDocumentAsync(selfLinkId)).Resource;
ResourceResponse<Attachment> resp = await _client.CreateAttachmentAsync(foundDocument.AttachmentsLink, mediaStream, new MediaOptions { ContentType = contentType, Slug = fileName, });
string mediaLink = resp.Resource.MediaLink;
return mediaLink;
}
public async Task<MediaResponse> GetAttachment(string mediaLink)
{
//Use DocumentClient to read the Media content
MediaResponse content = await _client.ReadMediaAsync(mediaLink);
return content;
}
【问题讨论】:
标签: azure azure-cosmosdb