dio icon indicating copy to clipboard operation
dio copied to clipboard

Flutter Web: Read filename from Headers

Open SofiSheromova opened this issue 2 years ago • 2 comments

Is there anyway to get the filename from Content-Disposition headers aside from specifying a filename for Web?

SofiSheromova avatar Jun 06 '22 10:06 SofiSheromova

try this:

await dio.download(
      url,

      (HttpHeaders headers){

        // parse `content-disposition ` here
        return "$filename"
      },
    );

riccardopirani avatar Jun 06 '22 21:06 riccardopirani

I already found this answer in the issue https://github.com/flutterchina/dio/issues/258. Unfortunately, this method is not supported for web https://github.com/flutterchina/dio/blob/ac78e6151e1736f945cb9b215bbcfac230e19cf1/dio/lib/src/dio_mixin.dart#L362
it doesn't solve my problem.

SofiSheromova avatar Jun 07 '22 05:06 SofiSheromova

try this:

await dio.download(
      url,

      (HttpHeaders headers){

        // parse `content-disposition ` here
        return "$filename"
      },
    );

@riccardopirani Do you have a specific code?

BYDU avatar Oct 09 '22 16:10 BYDU

Use HEAD request instead of download.

AlexV525 avatar Dec 15 '22 16:12 AlexV525