App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2021-12-27] $500 - solution + reporting bonus. Android/iOS - User is able to upload a video of >50mb - Reported by: @akshayasalvi

Open isagoico opened this issue 5 years ago β€’ 34 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Navigate to a conversation
  2. Upload a video that is over 50mb

Expected Result:

There should be a error message about the upload limit of 50mb

Actual Result:

User is able to upload the >50mb video

Workaround:

None needed.

Platform:

Where is this issue occurring?

  • iOS
  • Android

Version Number: 1.1.8-2

Reproducible in staging?: Yes Reproducible in production?: Yes

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

https://user-images.githubusercontent.com/44479856/137604015-c2fbbed5-3fa5-41fb-8610-9e5e75accf0f.mp4

Expensify/Expensify Issue URL:

Issue reported by: @akshayasalvi Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1634322848367700

View all open jobs on GitHub

isagoico avatar Oct 16 '21 23:10 isagoico

Triggered auto assignment to @cead22 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Oct 16 '21 23:10 MelvinBot

Triggered auto assignment to @Beamanator (Demolition), see https://stackoverflow.com/c/expensify/questions/8099 for more details.

MelvinBot avatar Oct 19 '21 00:10 MelvinBot

It doesn't look like the user is actually able to upload the video successfully, but the reproduction steps are clear and we should show an error messages instead of endless spinners

cead22 avatar Oct 19 '21 00:10 cead22

N6-hold ended, and changing to Weekly instead of daily b/c it's not super high priority. Will look into it later this week.

Beamanator avatar Oct 19 '21 22:10 Beamanator

Looking more into this later this week

Beamanator avatar Nov 01 '21 16:11 Beamanator

Not finding much time to work on this so far this week πŸ™ˆ

Beamanator avatar Nov 09 '21 19:11 Beamanator

@Beamanator I was retesting this and it looks like I closed this in another PR. (https://github.com/Expensify/App/pull/5900)

This commit fixed it. Earlier it basically failed to fetch the size for videos and allowed the user to upload.

akshayasalvi avatar Nov 12 '21 21:11 akshayasalvi

Hmm can you test again on Android or iOS? I believe I reproduced the issue a week ago, which is even after the PR you mention was merged to production

Beamanator avatar Nov 16 '21 15:11 Beamanator

I'll try again to reproduce this week in case it actually was fixed before

Beamanator avatar Nov 29 '21 13:11 Beamanator

@Beamanator So I was able to reproduce this. Problem is when the files are picked from photo gallery we are not getting the size parameter. It turns out thats a limitation from react-native-image-picker as size works for photos only.

If I upload the video using add Document API then I do get fileSize even for videos (which is what I was trying earlier), and it worked fine with my last commit.

Here's my proposal to fix this: We use rn-fetch-blob to get the file size incase we don't get fileSize and size both. Tested the below function for iOS and I am guessing it should work with Android too.

// Inside pickAttachment

getDataForUpload(attachment).then((result) => {
            this.completeAttachmentSelection(result);
        });


// Update getDataForUpload
function getDataForUpload(fileData) {
    return new Promise((resolve, reject) => {
        const fileResult = {
            name: fileData.fileName || fileData.name || 'chat_attachment',
            type: fileData.type,
            uri: fileData.uri,
            size: fileData.fileSize || fileData.size,
        };
        if (_.has(fileData, 'fileSize') || _.has(fileData, 'size')) {
            return resolve(fileResult);
        }

        RNFetchBlob.fs.stat(fileData.uri.replace('file://', '')).then((stats) => {
            fileResult.size = stats.size;
            return resolve(fileResult);
        }).catch(reject);
    });
}



akshayasalvi avatar Nov 29 '21 17:11 akshayasalvi

@akshayasalvi Thanks so much for looking into this! Since it looks like the issue is in the library, I'll mark this External

Beamanator avatar Nov 30 '21 13:11 Beamanator

Triggered auto assignment to @laurenreidexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Nov 30 '21 13:11 MelvinBot

@akshayasalvi just to be clear, if you're proposing to use rn-fetch-blob, you mean https://github.com/joltup/rn-fetch-blob right? It looks like that repo isn't maintained, so I would be pretty hesitant to use that one πŸ€”

Beamanator avatar Nov 30 '21 13:11 Beamanator

@Beamanator I saw that but I only proposed after checking that it is a part of our dependencies already

akshayasalvi avatar Nov 30 '21 13:11 akshayasalvi

@Beamanator I saw that but I only proposed after checking that it is a part of our dependencies already

Ooops I should have checked that, thanks for correcting me πŸ‘

Before I accept your proposal, would you mind testing in Android to make sure it works there too?

Beamanator avatar Nov 30 '21 14:11 Beamanator

@Beamanator Can confirm this works on Android as well.

image

akshayasalvi avatar Nov 30 '21 14:11 akshayasalvi

@akshayasalvi that's fantastic! One more thing I'm thinking about: if this is something we only want to do on native, maybe we should move it to /libs so we can easily have 1 function for web / desktop & 1 for native. What do you think?

Beamanator avatar Nov 30 '21 15:11 Beamanator

Yeah sure. That makes sense.

Quick question; solution that I mentioned was for native only. We do have AttachmentPicker separate for native and web. This code will go in AttachmentPicker/index.native.js only. Still want to move to libs? Or what I mentioned is fine.

akshayasalvi avatar Nov 30 '21 15:11 akshayasalvi

Aaahhhhh very good point, let's keep it in index.native.js πŸ‘ Thanks, you're hired!

Beamanator avatar Nov 30 '21 16:11 Beamanator

πŸ“£ @akshayasalvi You have been assigned to this job by @Beamanator! Please apply to this job in Upwork and let us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

MelvinBot avatar Nov 30 '21 16:11 MelvinBot