Skip to content

cpExternal to 'downloads' works in Android but not in iOS #41

Open
@afilp

Description

@afilp

Hello,

While it works in iOS, the cpExternal does not work in iOS. Note that I have both UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace enabled. Testing in emulator. Shouldn't the destination ('downloads') be a "common" folder and not an application-specific folder?

Is this a bug or a non-proper implementation?

Thanks a lot!

image

const fetchPayment = async (paymentId, createdDate) => {
  const token = await getAuthToken();
  console.log('token', token);

  const destPath = `${Dirs.CacheDir}/${createdDate}-Invoice.pdf`;

  // const date = new Date();
  const { data } = await new Promise((resolve, reject) => {
    try {
      FileSystem.fetch(
        `${window.our.BASE_URL}/payment?paymentId=${paymentId}`,
        {
          headers: {
            Authorization: `Bearer ${token}`,
            Accept: 'application/pdf',
            'Content-Type': 'application/pdf',
          },
          path: destPath,
        },
      )
        .then(async res => {
          console.log('res', res);
          await FileSystem.cpExternal(
            destPath,
            `${createdDate}-Invoice.pdf`,
            'downloads',
          );
          Alert.alert(
            t('invoiceDownloaded'),
            t('invoiceDownloadedAndroidFolder'),
          );
          resolve(res);
        })
        // Something went wrong:
        .catch((errorMessage, statusCode) => {
          console.log(errorMessage);
          reject(errorMessage);
        });
    } catch (err) {
      console.log(err);
      reject(err);
    }
  });
  return data;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions