The majority of the context is contained in the Linear task (https://linear.app/comm/issue/ENG-2924/use-the-internal-ip-package-in-the-dev-environment-to-ensure-physical). In short, the current shimUploadURI will detect what OS the user is on, and if it's iOS return localhost and if it's Android return 10.0.2.2. This works fine for the emulators, but makes testing uploads on physical devices difficult because we'd need to use a different method and get the accessing devices' IPv4 address to return in the upload url. By removing shimUploadURI and always using the IPv4 address (regardless of emulator or physical device), we keep the logic consistent between testing devices. Handling the logic to do this directly within getUploadURL allows all uploads when fetched to return to an address that is accessible across all dev environments.
Another note: I looked through D6266 prior to working on this, and while it looks like internal-ip version 7.0.0 worked fine within the keyserver, I chose to use version 4.3.0 in an effort to keep consistent. If we want to change to 7.0.0, there should only be four things that need to be done:
- Change the version in devDependencies
- Change the import from import ip from 'internal-ip to import { internalIpV4Sync } from 'internal-ip' to prevent SyntaxError: The requested module 'internal-ip' does not provide an export named 'default'
- Change the use of ip.v4.sync() to internalIpV4Sync() in getUploadURL.
- Run yarn dev in native and ensure that it still works (see @bartek's comment below)
Adding @ashoat as blocking since it involves a dependency
Depends on D6531