Skip to content

[Android] 'size' is negative value for files over 2GB #599

@HongSeokJong

Description

@HongSeokJong

Hello! I am not good at English, so I write with the help of a translator. I ask for your understanding 😂

Feature request

In the case of a file larger than 2GB on Android, size is a negative value as a result of DocumentPicker.pick (It works fine on iOS)

Why it is needed

There is a part that selects a file and processes it using the size of the file. It does not work properly when selecting a file larger than 2GB on Android.

Possible implementation

In getMetadata() of DocumentPickerModule.java, FIELD_SIZE is being treated as int. Changing this to treat it as double works fine.

Code sample

Current code

private WritableMap getMetadata(Uri uri) {
  // ...
          if (!cursor.isNull(sizeIndex)) {
            map.putInt(FIELD_SIZE, cursor.getInt(sizeIndex));  // <-- this line!
          } else {
            map.putNull(FIELD_SIZE);
          }
  // ...
}

New code

private WritableMap getMetadata(Uri uri) {
  // ...
          if (!cursor.isNull(sizeIndex)) {
            map.putDouble(FIELD_SIZE, cursor.getDouble(sizeIndex));  // treat as 'double' 🤗
          } else {
            map.putNull(FIELD_SIZE);
          }
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions