Limit size of video uploaded from camera roll in android

Summary: Details in Task T53266042. AMA users are trying to upload video data of more than 300 MB which is causing spikes of server_err in the web tier. So i added check to retrive videos that have size < 100 MB.

Reviewed By: furdei

Differential Revision: D17544308

fbshipit-source-id: 5a1d1329b6b12656f1617bb8775e303c96d529cb
This commit is contained in:
Rajdeep Kaur 2019-09-26 09:45:24 -07:00 коммит произвёл Facebook Github Bot
Родитель 5e68a98c3d
Коммит d21f695edf
1 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -82,6 +82,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
private static final String SELECTION_BUCKET = Images.Media.BUCKET_DISPLAY_NAME + " = ?";
private static final String SELECTION_DATE_TAKEN = Images.Media.DATE_TAKEN + " < ?";
private static final String SELECTION_MEDIA_SIZE = Images.Media.SIZE + " < ?";
public CameraRollManager(ReactApplicationContext reactContext) {
super(reactContext);
@ -228,13 +229,21 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
String assetType =
params.hasKey("assetType") ? params.getString("assetType") : ASSET_TYPE_PHOTOS;
Integer maxSize = params.hasKey("maxSize") ? params.getInt("maxSize") : null;
ReadableArray mimeTypes = params.hasKey("mimeTypes") ? params.getArray("mimeTypes") : null;
if (params.hasKey("groupTypes")) {
throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
}
new GetMediaTask(
getReactApplicationContext(), first, after, groupName, mimeTypes, assetType, promise)
getReactApplicationContext(),
first,
after,
groupName,
mimeTypes,
assetType,
maxSize,
promise)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -246,6 +255,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
private final @Nullable ReadableArray mMimeTypes;
private final Promise mPromise;
private final String mAssetType;
private final @Nullable Integer mMaxSize;
private GetMediaTask(
ReactContext context,
@ -254,6 +264,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
@Nullable String groupName,
@Nullable ReadableArray mimeTypes,
String assetType,
@Nullable Integer maxSize,
Promise promise) {
super(context);
mContext = context;
@ -263,6 +274,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
mMimeTypes = mimeTypes;
mPromise = promise;
mAssetType = assetType;
mMaxSize = maxSize;
}
@Override
@ -277,6 +289,10 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
selection.append(" AND " + SELECTION_BUCKET);
selectionArgs.add(mGroupName);
}
if (mMaxSize != null) {
selection.append(" AND " + SELECTION_MEDIA_SIZE);
selectionArgs.add(mMaxSize.toString());
}
switch (mAssetType) {
case ASSET_TYPE_PHOTOS: