Bug 65027 - HTTP Sampler/Files upload tab - auto detect MIME type of selected file
Summary: HTTP Sampler/Files upload tab - auto detect MIME type of selected file
Status: NEW
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: JMETER 5.4.1
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2020-12-25 18:13 UTC by eR@SeR
Modified: 2021-02-15 02:03 UTC (History)
0 users



Attachments
auto detect mime type (60.88 KB, image/jpeg)
2020-12-25 18:13 UTC, eR@SeR
Details
Detect mimetype automatically, when no mimetype is given (5.06 KB, patch)
2020-12-30 11:39 UTC, Felix Schumacher
Details | Diff
postman content-type (35.68 KB, image/jpeg)
2021-01-04 19:40 UTC, eR@SeR
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eR@SeR 2020-12-25 18:13:06 UTC
Created attachment 37648 [details]
auto detect mime type

Hello,

When one or more files are selected to upload in HTTP Sampler/Files upload tab, the file path is generated but the MIME type isn't. IMO, it is better to auto-detect MIME type of selected file, than to type it manually every time.

Jmeter 5.4.1 9d2ba68
Microsoft Windows 10 Pro 64-bit
java version "1.8.0_251"
Comment 1 Felix Schumacher 2020-12-30 11:39:40 UTC
Created attachment 37673 [details]
Detect mimetype automatically, when no mimetype is given
Comment 2 Felix Schumacher 2020-12-30 11:40:32 UTC
@all, should we change the behaviour to autodetect?
Comment 3 eR@SeR 2021-01-04 19:40:57 UTC
Created attachment 37686 [details]
postman content-type

Hi,

I added the image of Content-Type column from Body/Form-data - Postman. What I noticed is:

1. If left blank, the placeholder "Auto" is shown. Postman automatically assigns a content type.

Maybe to use the same approach in JMeter?

----

2. If user starts to type in text box, suggestions will pop up and help him to choose one from the list.

I guess Tika could be used to generate the list in JMeter.

----

Two more things to consider for improvement and possible solutions for auto-detect implementation.
Comment 4 Felix Schumacher 2021-02-11 19:05:50 UTC
@Nikola, could you test the next build from trunk or nightly?

The other suggestions like adding "auto" for auto-detecting or auto-complete while typing are nice ideas, but I am not sure, how to implement those. Maybe it is a good idea to put them on their own enhancement issues :)


commit 9326c3febe435307d36e904412593c2c2badf987
AuthorDate: Wed Dec 30 12:34:08 2020 +0100

    Detect mime-type for files automatically when adding files to HTTP Sampler
    
    Bugzilla Id: 65027
---
 .../jmeter/protocol/http/util/HTTPFileArg.java     | 40 +++++++++++++++++++++-
 .../jmeter/protocol/http/util/TestHTTPFileArg.java |  2 +-
 .../protocol/http/util/TestHTTPFileArgs.java       | 10 +++---
 xdocs/changes.xml                                  |  1 +
 xdocs/usermanual/component_reference.xml           | 10 +++---
 5 files changed, 52 insertions(+), 11 deletions(-)
Comment 5 eR@SeR 2021-02-15 02:03:00 UTC
Hi Felix,

It seems that autodetection works by scanning file path text box, not actual file that is browsed on disk, so user can type non existing file path and detection will work (MIME type gets filled) - which is fine by me.

However, if user changes already provided file path, be it existing or not, MIME type box remains unchanged. Current implementation is not good enough since user has to remove MIME type text entirely in order to redetect it. I suggest that on every file path change, autodetection fills new or replaces current MIME type.

(In reply to Felix Schumacher from comment #4)
> @Nikola, could you test the next build from trunk or nightly?
> 
> The other suggestions like adding "auto" for auto-detecting or auto-complete
> while typing are nice ideas, but I am not sure, how to implement those.
> Maybe it is a good idea to put them on their own enhancement issues :)
Enhancement has been opened - https://bz.apache.org/bugzilla/show_bug.cgi?id=65139

Jmeter 5.5 acdb648
Microsoft Windows 10 Pro 64-bit
java version "15.0.1" 2020-10-20