コード例 #1
0
        public async Task UpdatePictureAsync(string id, [FromForm] MultiPartFile picture)
        {
            const int maxFileSize = (int)10e6;

            if (picture?.File == null)
            {
                throw new ArgumentNullException(nameof(picture));
            }

            var objectId = await CanWriteDataToResidentAsync(id);

            try
            {
                var bytes = picture.ConvertToBytes(maxFileSize);

                await DataService.UpdatePropertyAsync(objectId, x => x.Picture, bytes);
            }
            catch (FileToLargeException)
            {
                throw new FileToLargeException(maxFileSize);
            }
        }