@@ -68,8 +68,8 @@ public async Task<ActionResult<Gathering>> CreateGathering([FromForm] GatheringR
6868 }
6969
7070 if ( coverImg != null ) {
71- Uri uri = await UploadCoverImage ( gatheringReqDto . GatheringId , coverImg : coverImg ?? throw new ArgumentNullException ( nameof ( coverImg ) ) ) ;
72- gatheringReqDto = gatheringReqDto with { CoverSrc = uri . AbsoluteUri } ;
71+ string uri = await UploadCoverImage ( gatheringReqDto . GatheringId , coverImg ) ;
72+ gatheringReqDto = gatheringReqDto with { CoverSrc = uri } ;
7373 }
7474
7575 Gathering gathering = await gatheringService . CreateGathering ( gatheringReqDto ) ;
@@ -88,9 +88,8 @@ public async Task<ActionResult> UpdateGathering(long gatheringId, [FromForm] Gat
8888 }
8989
9090 if ( coverImg != null ) {
91- Uri uri = await UploadCoverImage ( gatheringReqDto . GatheringId , coverImg ) ;
92- gathering . CoverSrc = uri . AbsoluteUri ;
93- gatheringReqDto = gatheringReqDto with { CoverSrc = uri . AbsoluteUri } ;
91+ string uri = await UploadCoverImage ( gatheringReqDto . GatheringId , coverImg ) ;
92+ gatheringReqDto = gatheringReqDto with { CoverSrc = uri } ;
9493 }
9594
9695 gathering = await gatheringService . UpdateGathering ( gatheringId , gatheringReqDto ) ;
@@ -112,16 +111,17 @@ public async Task<ActionResult<Gathering>> DeleteGathering(long gatheringId) {
112111 return NoContent ( ) ;
113112 }
114113
115- private async Task < Uri > UploadCoverImage ( long gatheringId , IFormFile coverImg ) {
114+ private async Task < string > UploadCoverImage ( long gatheringId , IFormFile coverImg ) {
116115 string fileName = $ "gatherings/{ gatheringId } /cover-image{ Path . GetExtension ( coverImg . FileName ) } ";
117116 BinaryData binaryData = await coverImg . ToBinaryData ( ) ;
118117 bool isContentSafe = await objectStorageService . PassesContentModeration ( binaryData ) ;
119118 if ( ! isContentSafe ) {
120- return new Uri ( string . Empty , UriKind . RelativeOrAbsolute ) ;
119+ return string . Empty ;
121120 }
122- return await objectStorageService . UploadFile ( _containerName ,
121+ Uri uri = await objectStorageService . UploadFile ( _containerName ,
123122 fileName ,
124123 binaryData ,
125124 mimeType : MimeTypes . GetMimeType ( coverImg . FileName ) ) ;
125+ return uri . AbsoluteUri ;
126126 }
127127}
0 commit comments