react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

DownloadFile returning status code 400 after redirect on ios 13, while working on ios 12

Open amauryVedana opened this issue 5 years ago • 4 comments
trafficstars

I'm using RNFS.downloadFile to call an url which redirect me to an other url (with 302) to download a file. On ios 12 it is working well, however on ios 13 (13.4) it returns me a status code 400.

const CallWebApiDownload = async (
    options: IServiceArguments,
    destinationPath: string,
    onProgress: (res: any) => void
) => {
    const loginReducerParameters = await getApiCallParameters(options);
    const requestId = getRequestId();

    const res = RNFS.downloadFile({
        fromUrl: options.path,
        toFile: destinationPath,
        headers: getHeader(loginReducerParameters, requestId),
        progress: onProgress,
        progressInterval: 10,
        progressDivider: 5
    });
    await res.promise
    return res
};

this happens both on simulator and real device. I managed to make it works using rn-fetch-blob. Anyone having the same problem ?

amauryVedana avatar May 06 '20 15:05 amauryVedana

Turns out that the headers would be forwarded in redirection which may cause some servers to reject

sunnylqm avatar May 13 '20 08:05 sunnylqm

Yes, i'm 90% sure it's what happens to my side too

amauryVedana avatar May 13 '20 08:05 amauryVedana

Any fix for this one?

lanceliamll avatar May 25 '22 09:05 lanceliamll