@@ -277,23 +277,29 @@ public async Task<IActionResult> GetFileByTfmId(string id, [FromQuery] string id
277277 {
278278 return new ObjectResult ( "" ) { StatusCode = ( int ) HttpStatusCode . NotFound } ;
279279 }
280- var file = _fs . ExistFileIntempFolder ( $ "{ idChannel } -{ dbFile . MessageId } -{ id } ") ;
280+ var file = _fs . ExistFileIntempFolder ( $ "{ idChannel } -{ ( dbFile . MessageId != null ? dbFile . MessageId . ToString ( ) : dbFile . Id ) } -{ id } ") ;
281281 if ( file == null )
282282 {
283- TL . Message idM = await _ts . getMessageFile ( idChannel , Convert . ToInt32 ( dbFile . MessageId ) ) ;
284- ChatMessages cm = new ChatMessages ( ) ;
285- cm . message = idM ;
286- file = new FileStream ( System . IO . Path . Combine ( FileService . TEMPDIR , "_temp" , $ "{ idChannel } -{ idFile } -{ id } ") , FileMode . Create , FileAccess . ReadWrite ) ;
287- DownloadModel dm = new DownloadModel ( ) ;
288- dm . tis = _tis ;
289- dm . channelName = _ts . getChatName ( Convert . ToInt64 ( idChannel ) ) ;
290- _tis . addToDownloadList ( dm ) ;
291- await _ts . DownloadFileAndReturn ( cm , file , model : dm ) ;
292- file . Position = 0 ;
283+ _fs . downloadFile ( idChannel , new List < Syncfusion . Blazor . FileManager . FileManagerDirectoryContent > { dbFile . toFileManagerContent ( ) } , System . IO . Path . Combine ( FileService . TEMPDIR , "_temp" , $ "{ idChannel } -{ ( dbFile . MessageId != null ? dbFile . MessageId . ToString ( ) : dbFile . Id ) } -{ id } ") ) ;
284+ //TL.Message idM = await _ts.getMessageFile(idChannel, Convert.ToInt32(dbFile.MessageId));
285+ //ChatMessages cm = new ChatMessages();
286+ //cm.message = idM;
287+ //file = new FileStream(System.IO.Path.Combine(FileService.TEMPDIR, "_temp", $"{idChannel}-{idFile}-{id}"), FileMode.Create, FileAccess.ReadWrite);
288+ //DownloadModel dm = new DownloadModel();
289+ //dm.tis = _tis;
290+ //dm.channelName = _ts.getChatName(Convert.ToInt64(idChannel));
291+ //_tis.addToDownloadList(dm);
292+ //await _ts.DownloadFileAndReturn(cm, file, model: dm);
293+ //file.Position = 0;
293294 }
294295
295- Response . Headers [ "Content-Disposition" ] = $ "inline; filename=\" { HttpUtility . UrlEncode ( fileName ) } \" ";
296+ if ( file == null )
297+ {
298+ return NotFound ( ) ;
299+ }
296300
301+ Response . Headers [ "Content-Disposition" ] = $ "inline; filename=\" { HttpUtility . UrlEncode ( fileName ) } \" ";
302+
297303 return new FileStreamResult ( file , mimeType ) ;
298304 }
299305
0 commit comments