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

[android] return the 'originFilepath' when select image #2077

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IceOfSummer
Copy link

Thanks for submitting a PR! Please read these instructions carefully:

  • Explain the motivation for making this change.
  • Provide a test plan demonstrating that the code is solid.
  • Match the code formatting of the rest of the codebase.
  • Target the main branch, NOT a "stable" branch.

Motivation (required)

Many app want to use the filename/filepath as a key to avoid their image to be upload twice or more.
But the existing module return a temporary filepath and filename, we can not distinct each image that we select!

Test Plan (required)

[1]: In this video, I select a image twice, it returns the same originFilepath.

2023_02_05_14_18_07.-.Compressed.with.FlexClip.mp4

related test code:

  pickerCallback(response: ImagePickerResponse) {``
    if (!response.errorCode) {
      const assets = response.assets
      if (!assets) {
        return
      }
      // show result here
      showSingleBtnTip('response', JSON.stringify(response))
      console.log(response)
    }
  }

  onSelect(index: number) {
    if (index === 0) {
      launchCamera({ mediaType: 'photo' })
        .then(this.pickerCallback)
        .catch(e => {
          Toast.show('打开相机失败: ' + e.message)
        })
        .finally(() => {
          this.drawer.current?.closeDrawer()
        })
    } else if (index === 1) {
      launchImageLibrary({ selectionLimit: 1, mediaType: 'photo' })
        .then(this.pickerCallback)
        .catch(e => {
          Toast.show('打开图库失败: ' + e.message)
        })
        .finally(() => {
          this.drawer.current?.closeDrawer()
        })
    }
  }

@IceOfSummer
Copy link
Author

#1569

@kueda
Copy link

kueda commented Mar 21, 2023

FWIW, this would help https://github.com/inaturalist/iNaturalistReactNative out because we need access to the original file path in order to extract the original EXIF data, if present, including fields this library does not extract, like GPSHPositioningError.

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

Successfully merging this pull request may close these issues.

None yet

2 participants