Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload to Dropbox not working #855

Open
Stophface opened this issue Sep 8, 2023 · 0 comments
Open

Upload to Dropbox not working #855

Stophface opened this issue Sep 8, 2023 · 0 comments

Comments

@Stophface
Copy link

I am trying to upload a rather large file (~100mb) to Dropbox. The response I am getting from rn-fetch-blob is that it worked, however, there is a) nothing in my Dropbox and b) the upload takes about 1sec which is way too short for ~100mb.

  const _authenticateDropbox = async () => {
    const config = {
      clientId: '...',
      clientSecret: '...
      redirectUrl: 'org.reactjs.native.example..../oauth',
      scopes: [],
      serviceConfiguration: {
        authorizationEndpoint: 'https://www.dropbox.com/oauth2/authorize',
        tokenEndpoint: `https://www.dropbox.com/oauth2/token`,
      },
      additionalParameters: {
        token_access_type: 'offline',
      },
    };
    try {
      const user = await authorize(config);
      if (user) {
        if (user.accessToken) _uploadData(user.accessToken);
      }
    } catch (error) {
      console.warn('Something went wrong logging in into Dropbox, ', error);
    }
  };

  const _uploadData = accessToken => {
    const dbName = `${DATABASE_NAME}.db`;
    const databasePath = `${RNFS.DocumentDirectoryPath}/${dbName}`;

      RNFetchBlob.fetch(
        'POST',
        'https://content.dropboxapi.com/2/files/upload',
        {
          Authorization: accessToken,
          'Dropbox-API-Arg': JSON.stringify({
            path: '/foo.db',
            mode: 'add',
            autorename: true,
            mute: false,
          }),
          'Content-Type': 'application/octet-stream',
        },
        RNFetchBlob.wrap(databasePath),
      )
        .uploadProgress({interval: 250}, (written, total) => {
          ...
        })
        .then(res => {
          ...
        })
        .catch(error => {
          ...
        });
  };

Additionally, the total propb of uploadProgress() is 0 all the time. Am I doing something wrong?

Versions:
"react-native": "0.71.7",
"rn-fetch-blob": "^0.12.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant