@@ -262,6 +262,36 @@ public async Task<IActionResult> GetFile(string id, string? idChannel, string? i
262262 } ;
263263 }
264264
265+ [ Route ( "GetFileByTfmIdNow/{id}" ) ]
266+ public async Task < IActionResult > GetFileByTfmIdNow ( string id , [ FromQuery ] string idChannel , [ FromQuery ] string idFile )
267+ {
268+ var fileName = id ;
269+ var mimeType = FileService . getMimeType ( id . Split ( "." ) . Last ( ) ) ;
270+ var dbFile = await _fs . getItemById ( idChannel , idFile ) ;
271+ if ( dbFile == null )
272+ {
273+ return new ObjectResult ( "" ) { StatusCode = ( int ) HttpStatusCode . NotFound } ;
274+ }
275+ var file = _fs . ExistFileIntempFolder ( $ "{ idChannel } -{ dbFile . MessageId } -{ id } ") ;
276+ if ( file == null )
277+ {
278+ TL . Message idM = await _ts . getMessageFile ( idChannel , Convert . ToInt32 ( dbFile . MessageId ) ) ;
279+ ChatMessages cm = new ChatMessages ( ) ;
280+ cm . message = idM ;
281+ file = new FileStream ( System . IO . Path . Combine ( FileService . TEMPDIR , "_temp" , $ "{ idChannel } -{ idFile } -{ id } ") , FileMode . Create , FileAccess . ReadWrite ) ;
282+ DownloadModel dm = new DownloadModel ( ) ;
283+ dm . tis = _tis ;
284+ dm . channelName = _ts . getChatName ( Convert . ToInt64 ( idChannel ) ) ;
285+ _tis . addToDownloadList ( dm ) ;
286+ await _ts . DownloadFileAndReturn ( cm , file , model : dm ) ;
287+ file . Position = 0 ;
288+ }
289+
290+ Response . Headers [ "Content-Disposition" ] = $ "inline; filename=\" { HttpUtility . UrlEncode ( fileName ) } \" ";
291+
292+ return new FileStreamResult ( file , mimeType ) ;
293+ }
294+
265295 [ Route ( "GetFileByTfmId/{id}" ) ]
266296 public async Task < IActionResult > GetFileByTfmId ( string id , [ FromQuery ] string idChannel , [ FromQuery ] string idFile )
267297 {
0 commit comments