Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Permission Denied #500

Closed
Skn0tt opened this issue Aug 22, 2017 · 4 comments
Closed

Permission Denied #500

Skn0tt opened this issue Aug 22, 2017 · 4 comments

Comments

@Skn0tt
Copy link

Skn0tt commented Aug 22, 2017

Hey there,
I have a problem with sending a file as a blob. The Code Snippet below comes from a React-Native app. I have to get Permissions because of the Permissions System in Android, and whenever the RNFetchBlob.fetch(...) runs, it outputs this:

RNFetchBlob failed to create single content request body :error when getting request stream: Permission denied

Since the server I PUT to doesn't spit an error, I suspect this is a local issue. Since this isn't covered in the README, I figured maybe you can help me 😄

Sincerely,
Simon

DocumentPicker.show({
  filetype: [DocumentPickerUtil.allFiles()],
}, (err, res) => {
  PermissionsAndroid.requestMultiple(
      [
        PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
        PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      ], {
        title: 'Permission',
        message: 'We need your permission.',
      },
    )
    .then((permRes) => {
      if (permRes['android.permission.READ_EXTERNAL_STORAGE'] === PermissionsAndroid.RESULTS.GRANTED &&
        permRes['android.permission.WRITE_EXTERNAL_STORAGE'] === PermissionsAndroid.RESULTS.GRANTED) {
        const {
          user,
          pass,
          uri
        } = this.props.currentShare
        const destination = `${uri}/${res.fileName}`
        const src = RNFetchBlob.wrap(encodeURI(res.uri))
        RNFetchBlob.fetch(
          'PUT',
          destination, {
            Authorization: `Basic ${new Buffer(`${user}:${pass}`).toString('base64')}`,
            'User-Agent': 'BSync/1.0.0',
            'Content-Type': res.type,
          },
          src,
        )
      } else console.warn('Permission Denied')
    })
    .catch(err => console.warn(err))
})
@mohamedtijani
Copy link

@Skn0tt you fixed the error?

@Skn0tt
Copy link
Author

Skn0tt commented Jan 24, 2018

Yes i did, dont remember how anymore....

@Skn0tt Skn0tt reopened this Jan 24, 2018
@Skn0tt Skn0tt closed this as completed Jan 24, 2018
@mohamedtijani
Copy link

@Skn0tt can you send me the solution please

1 similar comment
@RichardValadares
Copy link

@Skn0tt can you send me the solution please

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.