feat: Added fileSize for getPhotos API (#180)

Co-authored-by: Antonio Gallo <antgallo@amazon.com>
This commit is contained in:
Antonio Gallo 2020-05-20 19:35:59 +02:00 committed by GitHub
parent 306bc75027
commit e7cf8665d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 1 deletions

View File

@ -183,6 +183,7 @@ Returns a Promise which when resolved will be of the following shape:
* `filename`: {string}
* `height`: {number}
* `width`: {number}
* `fileSize`: {number}
* `isStored`: {boolean}
* `playableDuration`: {number}
* `timestamp`: {number}

View File

@ -79,6 +79,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
Images.Media.DATE_TAKEN,
MediaStore.MediaColumns.WIDTH,
MediaStore.MediaColumns.HEIGHT,
MediaStore.MediaColumns.SIZE,
MediaStore.MediaColumns.DATA
};
@ -465,13 +466,14 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN);
int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH);
int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT);
int sizeIndex = media.getColumnIndex(MediaStore.MediaColumns.SIZE);
int dataIndex = media.getColumnIndex(MediaStore.MediaColumns.DATA);
for (int i = 0; i < limit && !media.isAfterLast(); i++) {
WritableMap edge = new WritableNativeMap();
WritableMap node = new WritableNativeMap();
boolean imageInfoSuccess =
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, dataIndex, mimeTypeIndex);
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, sizeIndex, dataIndex, mimeTypeIndex);
if (imageInfoSuccess) {
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
putLocationInfo(media, node, dataIndex);
@ -506,6 +508,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
int idIndex,
int widthIndex,
int heightIndex,
int sizeIndex,
int dataIndex,
int mimeTypeIndex) {
WritableMap image = new WritableNativeMap();
@ -516,6 +519,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
image.putString("filename", strFileName);
float width = media.getInt(widthIndex);
float height = media.getInt(heightIndex);
long fileSize = media.getLong(sizeIndex);
String mimeType = media.getString(mimeTypeIndex);
@ -575,6 +579,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
}
image.putDouble("width", width);
image.putDouble("height", height);
image.putDouble("fileSize", fileSize);
node.putMap("image", image);
return true;

View File

@ -354,6 +354,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
@"filename": origFilename,
@"height": @([asset pixelHeight]),
@"width": @([asset pixelWidth]),
@"fileSize": [resource valueForKey:@"fileSize"],
@"isStored": @YES, // this field doesn't seem to exist on android
@"playableDuration": @([asset duration]) // fractional seconds
},

View File

@ -78,6 +78,7 @@ export type PhotoIdentifier = {
uri: string,
height: number,
width: number,
fileSize: number,
isStored?: boolean,
playableDuration: number,
},

View File

@ -39,6 +39,7 @@ declare namespace CameraRoll {
uri: string,
height: number,
width: number,
fileSize: number,
isStored?: boolean,
playableDuration: number,
},