-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video - Invalid file is downloaded when downloading video #37092
Comments
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
|
We think that this bug might be related to #vip-vsp |
ProposalPlease re-state the problem that we are trying to solve in this issue.Video - Invalid file is downloaded when downloading video What is the root cause of that problem?The issue with download being not working as expected for videos is that - in case of video App/src/pages/home/report/ContextMenu/ContextMenuActions.tsx Lines 168 to 176 in 7f51d03
It works in case of images cause it parses the image for html tag. App/src/libs/fileDownload/index.ts Line 32 in 7f51d03
Here as What changes do you think we should make in order to solve the problem?We can change the code for const fileName = originalFileName ?? (reportAction?.attachmentInfo?.name ?? '') For popover menu in video player App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js Lines 26 to 31 in 72bdedb
const fName = currentlyPlayingURL.split('/').pop() || ''; This will ensure that we are using things that are already present without passing prop upto three levels and changing already existing things. Result for popverScreen.Recording.2024-02-23.at.8.00.43.AM.movAlternatively, we can apply file extension manually based on type of blob. ResultScreen.Recording.2024-02-23.at.12.06.43.AM.mov |
finding offending PR |
ProposalPlease re-state the problem that we are trying to solve in this issue.What is the root cause of that problem?The
Also in App/src/libs/fileDownload/FileUtils.ts Line 90 in 4a885f5
What changes do you think we should make in order to solve the problem?We could do something similar to App/src/components/Attachments/AttachmentCarousel/extractAttachmentsFromReport.js Lines 22 to 27 in 392efc7
Demo code: const IS_VIDEO_TAG = /<video([\w\W]+?)<\/video>/i.test(html);
const splittedUrl = html.match(SOURCE_REGEX)?.[1]?.split('/');
let videoOriginalFileName = '';
if (IS_VIDEO_TAG) {
videoOriginalFileName = splittedUrl ? splittedUrl[splittedUrl.length - 1] : '';
}
const originalFileName = IS_VIDEO_TAG ? videoOriginalFileName : html.match(ORIGINAL_FILENAME_REGEX)?.[1] ?? null; We need to do the same thing in const downloadAttachment = useCallback(() => {
currentVideoPlayerRef.current.getStatusAsync().then((status) => {
const sourceURI = `/${Url.getPathFromURL(status.uri)}`;
const parts = sourceURI.split('?');
const splittedURL = parts[0].split('/');
const filename = splittedURL[splittedURL.length - 1];
fileDownload(sourceURI, filename); Resultvideo_download_fix.mp4Alternative
Alternative 2Update function getFileName(url: string): string {
let fileName = url;
if (fileName.includes('?encryptedAuthToken=')) {
fileName = fileName.split('?encryptedAuthToken=')[0];
}
fileName = fileName.split(/[#?/]/).pop() ?? '';
if (!fileName) {
Log.warn('[FileUtils] Could not get attachment name', {url});
}
return decodeURIComponent(fileName).replace(CONST.REGEX.ILLEGAL_FILENAME_CHARACTERS, '_');
} Alternative 3If we need to use the original
const fileName = _.get(action, ['attachmentInfo', 'name'], '');
const html = _.get(action, ['message', 0, 'html'], '')
.replace('/>', `data-flagged="${hasBeenFlagged}" data-id="${action.reportActionID}"/>`)
.replace('<video', `<video ${CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE}="${fileName}"`);
const fileName = attribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE] || FileUtils.getFileName(`${source}`);
attachments.unshift({
reportActionID: null,
source,
isAuthTokenRequired: Boolean(attribs[CONST.ATTACHMENT_SOURCE_ATTRIBUTE]),
file: {name: fileName},
|
@BhuvaneshPatil Thanks for the proposal. Your RCA is correct. The solution looks good to me.
Edit: We have another case that we need to cover: the download button in the playback control buttons |
Triggered auto assignment to @deetergp, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@Krishna2323 Thanks for the proposal. Your RCA is correct. As for the solution it makes sense to extract the file name but I think it's better to just use the one available in |
@s77rt, selected proposal doesn't work with the popover in |
We won't get the App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js Lines 26 to 31 in 437d75c
Also, we are already filename from url in App/src/components/Attachments/AttachmentCarousel/extractAttachmentsFromReport.js Lines 22 to 27 in 392efc7
cc: @s77rt |
@Krishna2323 Thanks for brining this case up. I think we should cover that one too but I'd prefer to avoid such extraction. Can we instead pass the |
@s77rt, we can set state for |
|
@Krishna2323 Thanks for the update. I was checking again and I think we should just update |
@s77rt I have updated proposal that is easy tom implement without making lot of changes My thoughts on updating fileDownload utils is that it may be used at may places and can cause regression (very low probability, but still should be considered), by changing in VideoPopovercontext we are ensuring the change is limited to our scope for this issue. |
@BhuvaneshPatil, I already mentioned about getting fileName from url. |
@BhuvaneshPatil Thanks for the update. I still think we should update |
Triggered auto assignment to @dylanexpensify ( |
Adding the A wild @dylanexpensify appears… |
HELLO! |
Let's get this movin! |
@dylanexpensify, we are ready for payments here 😅, PR was deployed to production on 27th Feb. |
Sounds like we're just waiting on payments. |
Apologies, I've been OOO sick, but getting to this today! |
@dylanexpensify friendly bump for payments here :) |
Apologies, paying now! |
@dylanexpensify, I'm sorry if I'm disturbing you, but I still haven't been paid. 🙇🏻 |
Ahh no no not bothering me! @Krishna2323 paying literally right now! |
Payment summary:
Please apply here asap or request! |
@dylanexpensify, applied. |
@Krishna2323 offer sent! |
Accepted |
@Krishna2323 paid! |
Thanks :) |
thank YOU! |
@dylanexpensify Applied! Thanks! |
woooot! |
@s77rt sent offer!! |
Accepted! |
done! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 1.4.43-12
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
**Issue reported by:**Applause - Internal Team
Slack conversation:
Action Performed:
Expected Result:
The video is downloaded
Actual Result:
On web, mweb and desktop app, it downloads invalid file
On Android and iOS app, it shows error when downloading the video
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6388512_1708620575450.20240223_002702.mp4
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: