Пример #1
0
        public async Task <AttachmentMeta> AddAttachmentAsync(string country, string recordKey, Stream dataStream,
                                                              string fileName = null, string mimeType = null, bool upsert = false)
        {
            s_helper.Check <StorageClientException>(string.IsNullOrEmpty(recordKey),
                                                    Messages.Storage.s_errNullRecordKey);
            var invalidStream = dataStream == null || !dataStream.CanRead;

            s_helper.Check <StorageClientException>(invalidStream, Messages.Storage.s_errNullFileStream);

            if (string.IsNullOrEmpty(fileName))
            {
                if (dataStream is FileStream fileStream)
                {
                    fileName = Path.GetFileName(fileStream.Name);
                }
                else
                {
                    fileName = DefaultFileName;
                }
            }

            return(await _dao.AddAttachmentAsync(country?.ToLowerInvariant(),
                                                 _hashUtils.GetSha256Hash(recordKey), dataStream, fileName, upsert, mimeType).ConfigureAwait(false));
        }