feat: Added fileSize for getPhotos API (#180)
Co-authored-by: Antonio Gallo <antgallo@amazon.com>
This commit is contained in:
parent
306bc75027
commit
e7cf8665d4
|
@ -183,6 +183,7 @@ Returns a Promise which when resolved will be of the following shape:
|
||||||
* `filename`: {string}
|
* `filename`: {string}
|
||||||
* `height`: {number}
|
* `height`: {number}
|
||||||
* `width`: {number}
|
* `width`: {number}
|
||||||
|
* `fileSize`: {number}
|
||||||
* `isStored`: {boolean}
|
* `isStored`: {boolean}
|
||||||
* `playableDuration`: {number}
|
* `playableDuration`: {number}
|
||||||
* `timestamp`: {number}
|
* `timestamp`: {number}
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
|
||||||
Images.Media.DATE_TAKEN,
|
Images.Media.DATE_TAKEN,
|
||||||
MediaStore.MediaColumns.WIDTH,
|
MediaStore.MediaColumns.WIDTH,
|
||||||
MediaStore.MediaColumns.HEIGHT,
|
MediaStore.MediaColumns.HEIGHT,
|
||||||
|
MediaStore.MediaColumns.SIZE,
|
||||||
MediaStore.MediaColumns.DATA
|
MediaStore.MediaColumns.DATA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -465,13 +466,14 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
|
||||||
int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN);
|
int dateTakenIndex = media.getColumnIndex(Images.Media.DATE_TAKEN);
|
||||||
int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH);
|
int widthIndex = media.getColumnIndex(MediaStore.MediaColumns.WIDTH);
|
||||||
int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT);
|
int heightIndex = media.getColumnIndex(MediaStore.MediaColumns.HEIGHT);
|
||||||
|
int sizeIndex = media.getColumnIndex(MediaStore.MediaColumns.SIZE);
|
||||||
int dataIndex = media.getColumnIndex(MediaStore.MediaColumns.DATA);
|
int dataIndex = media.getColumnIndex(MediaStore.MediaColumns.DATA);
|
||||||
|
|
||||||
for (int i = 0; i < limit && !media.isAfterLast(); i++) {
|
for (int i = 0; i < limit && !media.isAfterLast(); i++) {
|
||||||
WritableMap edge = new WritableNativeMap();
|
WritableMap edge = new WritableNativeMap();
|
||||||
WritableMap node = new WritableNativeMap();
|
WritableMap node = new WritableNativeMap();
|
||||||
boolean imageInfoSuccess =
|
boolean imageInfoSuccess =
|
||||||
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, dataIndex, mimeTypeIndex);
|
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, sizeIndex, dataIndex, mimeTypeIndex);
|
||||||
if (imageInfoSuccess) {
|
if (imageInfoSuccess) {
|
||||||
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
|
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
|
||||||
putLocationInfo(media, node, dataIndex);
|
putLocationInfo(media, node, dataIndex);
|
||||||
|
@ -506,6 +508,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
|
||||||
int idIndex,
|
int idIndex,
|
||||||
int widthIndex,
|
int widthIndex,
|
||||||
int heightIndex,
|
int heightIndex,
|
||||||
|
int sizeIndex,
|
||||||
int dataIndex,
|
int dataIndex,
|
||||||
int mimeTypeIndex) {
|
int mimeTypeIndex) {
|
||||||
WritableMap image = new WritableNativeMap();
|
WritableMap image = new WritableNativeMap();
|
||||||
|
@ -516,6 +519,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
|
||||||
image.putString("filename", strFileName);
|
image.putString("filename", strFileName);
|
||||||
float width = media.getInt(widthIndex);
|
float width = media.getInt(widthIndex);
|
||||||
float height = media.getInt(heightIndex);
|
float height = media.getInt(heightIndex);
|
||||||
|
long fileSize = media.getLong(sizeIndex);
|
||||||
|
|
||||||
String mimeType = media.getString(mimeTypeIndex);
|
String mimeType = media.getString(mimeTypeIndex);
|
||||||
|
|
||||||
|
@ -575,6 +579,7 @@ public class CameraRollModule extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
image.putDouble("width", width);
|
image.putDouble("width", width);
|
||||||
image.putDouble("height", height);
|
image.putDouble("height", height);
|
||||||
|
image.putDouble("fileSize", fileSize);
|
||||||
node.putMap("image", image);
|
node.putMap("image", image);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -354,6 +354,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
||||||
@"filename": origFilename,
|
@"filename": origFilename,
|
||||||
@"height": @([asset pixelHeight]),
|
@"height": @([asset pixelHeight]),
|
||||||
@"width": @([asset pixelWidth]),
|
@"width": @([asset pixelWidth]),
|
||||||
|
@"fileSize": [resource valueForKey:@"fileSize"],
|
||||||
@"isStored": @YES, // this field doesn't seem to exist on android
|
@"isStored": @YES, // this field doesn't seem to exist on android
|
||||||
@"playableDuration": @([asset duration]) // fractional seconds
|
@"playableDuration": @([asset duration]) // fractional seconds
|
||||||
},
|
},
|
||||||
|
|
|
@ -78,6 +78,7 @@ export type PhotoIdentifier = {
|
||||||
uri: string,
|
uri: string,
|
||||||
height: number,
|
height: number,
|
||||||
width: number,
|
width: number,
|
||||||
|
fileSize: number,
|
||||||
isStored?: boolean,
|
isStored?: boolean,
|
||||||
playableDuration: number,
|
playableDuration: number,
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,6 +39,7 @@ declare namespace CameraRoll {
|
||||||
uri: string,
|
uri: string,
|
||||||
height: number,
|
height: number,
|
||||||
width: number,
|
width: number,
|
||||||
|
fileSize: number,
|
||||||
isStored?: boolean,
|
isStored?: boolean,
|
||||||
playableDuration: number,
|
playableDuration: number,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue