Skip to content
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

duplicate file extension when saveSnapshot #1980

Closed
1 task
clyer opened this issue Jul 13, 2023 · 1 comment · Fixed by #2419
Closed
1 task

duplicate file extension when saveSnapshot #1980

clyer opened this issue Jul 13, 2023 · 1 comment · Fixed by #2419
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@clyer
Copy link

clyer commented Jul 13, 2023

Which package is this bug report for? If unsure which one to select, leave blank

@crawlee/playwright (PlaywrightCrawler)

Issue description

  1. run saveSnapshot(page)
  2. expect SNAPSHOT.jpg saved, but got SNAPSHOT.jpg.jpeg. Also same issue with html file.

Key under which the screenshot and HTML will be saved. .jpg will be appended for screenshot and .html for HTML.

  1. The file name with extension has already been concatenated in playwright-utils, but in key-value-store, the extension is parsed based on "contentType" and concatenated again.

@crawlee/puppeteer has same issue.

Code sample

No response

Package version

3.4.0

Node.js version

16.15.1

Operating system

No response

Apify platform

  • Tick me if you encountered this issue on the Apify platform

I have tested this on the next release

No response

Other context

No response

@clyer clyer added the bug Something isn't working. label Jul 13, 2023
@mtrunkat mtrunkat added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 12, 2023
@damianr13
Copy link
Contributor

I encountered the same issue.

Here is what I found out about it:

The KeyValueStoreClient assigns an extension to the file based on the content type:

const extension = mime.extension(contentType) || DEFAULT_LOCAL_FILE_EXTENSION;
(that is our .jpeg extension)

The function saveSnapshot also assign an extension to the file:

(that is our .jpg extension)

My opinion is that KeyValueStoreClient should detect that the file name already has an extension that matches the content type and not add one anymore.

B4nan pushed a commit that referenced this issue Apr 22, 2024
Check if the key in a File Key Value Storage already has an extension. If so use the key as the file name directly, otherwise append extension.

Closes #1980
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants