itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.94k stars 975 forks source link

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

Open amauryVedana opened 4 years ago

amauryVedana commented 4 years ago

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 ?

sunnylqm commented 4 years ago

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

amauryVedana commented 4 years ago

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

lanceliamll commented 2 years ago

Any fix for this one?

Alex-us commented 1 month ago

Is there any progress?