[JIRA] (JENKINS-50772) Content type not set reasonably

20 views
Skip to first unread message

jglick@cloudbees.com (JIRA)

unread,
Apr 12, 2018, 12:58:02 PM4/12/18
to jenkinsc...@googlegroups.com
Jesse Glick created an issue
 
Jenkins / Bug JENKINS-50772
Content type not set reasonably
Issue Type: Bug Bug
Assignee: Unassigned
Components: artifact-manager-s3-plugin
Created: 2018-04-12 16:57
Priority: Minor Minor
Reporter: Jesse Glick

It seems that when you upload even a file named something.txt, it gets an octet-stream content type on S3, so even if you click the view link in Classic UI on the artifacts page, your browser gets a downloaded file rather than displaying inline. Must be some way to tell jClouds/S3 to sniff content type automatically. OTOH there may be some dangerous types which we would want to serve only as plain text or binary.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Jul 11, 2018, 2:54:02 PM7/11/18
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-50772
 
Re: Content type not set reasonably

MutableContentMetadata.setContentType? But Jenkins has no API for detecting content type of files.

Ideally VirtualFile.toExternalURL would allow you to pass a “view mode” parameter requesting a content type…if S3 supports that.

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

akdor1154@gmail.com (JIRA)

unread,
Sep 12, 2018, 1:03:02 AM9/12/18
to jenkinsc...@googlegroups.com

RobustHttpClient.uploadFile also has no way of setting a content type, which is another blocker for this I think?

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

akdor1154@gmail.com (JIRA)

unread,
Sep 12, 2018, 2:03:02 AM9/12/18
to jenkinsc...@googlegroups.com

(this is actually a blocker for our team to use this, "I can't see my test report when I click the link ")

akdor1154@gmail.com (JIRA)

unread,
Sep 12, 2018, 2:03:02 AM9/12/18
to jenkinsc...@googlegroups.com
Jarrad Whitaker edited a comment on Bug JENKINS-50772
(this is actually a blocker for our team to use this plugin , "I can't see my test report when I click the link :( ")

jglick@cloudbees.com (JIRA)

unread,
Sep 12, 2018, 2:36:01 PM9/12/18
to jenkinsc...@googlegroups.com

I doubt RobustHttpClient is involved; the content type setting would be done on the master side using the AWS SDK. I think. Will not know for sure until a fix is implemented. Perhaps David Currie wants to take a stab at it?

akdor1154@gmail.com (JIRA)

unread,
Sep 12, 2018, 8:10:02 PM9/12/18
to jenkinsc...@googlegroups.com

akdor1154@gmail.com (JIRA)

unread,
Sep 12, 2018, 8:11:03 PM9/12/18
to jenkinsc...@googlegroups.com

dcurrie@cloudbees.com (JIRA)

unread,
Sep 13, 2018, 4:42:14 AM9/13/18
to jenkinsc...@googlegroups.com

My reading is the same as Jarrad Whitaker. The S3 API indicates that the default Content-Type on a PUT is binary/octet-stream unless you specify otherwise.

jglick@cloudbees.com (JIRA)

unread,
Sep 13, 2018, 2:48:02 PM9/13/18
to jenkinsc...@googlegroups.com

Right, the question is whether the URL itself can encode the desired content type or whether this needs to be handled as an HTTP header by the uploading code. In the latter case, RobustHttpClient.uploadFile would need to be amended to set a header.

(Then the next question is what content type to pick. Files.probeContentType seems like the right choice.)

jglick@cloudbees.com (JIRA)

unread,
Sep 13, 2018, 2:48:02 PM9/13/18
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
 
Change By: Jesse Glick
Component/s: apache-httpcomponents-client-4-api-plugin

seppo.yliolli@gmail.com (JIRA)

unread,
May 10, 2019, 6:11:02 PM5/10/19
to jenkinsc...@googlegroups.com
Seppo Yli-Olli commented on Bug JENKINS-50772
 
Re: Content type not set reasonably

Even if you only populated content type for most common things (txt, html), this would still be useful. Is this being actively worked on? This limitation makes using HTML reports through Jenkins web UI quite painful if this plugin is active.

seppo.yliolli@gmail.com (JIRA)

unread,
May 10, 2019, 6:13:02 PM5/10/19
to jenkinsc...@googlegroups.com
Seppo Yli-Olli edited a comment on Bug JENKINS-50772
Even if you only populated content type for most common things (txt, html), this would still be useful. Is this being actively worked on? This limitation makes using HTML reports through Jenkins web UI quite painful if this plugin is active. My assumption based on what I've seen thus far is latter option is the right one but it could be that I'm just missing some details of presigned URL's.

robinverduijn.github@gmail.com (JIRA)

unread,
Oct 3, 2019, 8:47:03 PM10/3/19
to jenkinsc...@googlegroups.com

I took a stab at this, and was able to get a custom-built version of the plugin working for me locally: it uploads files to S3 with content-type set appropriately which makes them properly viewable in the browser (for inline file types such as text/plain and text/html) instead of always forcing them to be downloaded.

 

This took changes to both the artifact-manager-s3 and apache-httpcomponents-client-4-api-plugin repositories, since I had to ensure when the plugin performs an HTTP upload it also specifies the "Content-Type" header and I used a new method signature in RobustHTTPClient to do so.

 

My changes can be viewed at:

 

 

While, as I said, a custom plugin that has these changes appears to do the right thing for me and I also added several tests to verify uploads to (and subsequent downloads from) S3 are setting the content-type now, this is my first contribution to the project so I might well have missed something. Any suggestions or feedback welcome... I hope it at least provides a starting point for a fix to this issue, if nothing else.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Oct 4, 2019, 8:23:06 AM10/4/19
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Robin Verduijn
 
Change By: Jesse Glick
Assignee: Robin Verduijn

jglick@cloudbees.com (JIRA)

unread,
Oct 4, 2019, 8:23:07 AM10/4/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Oct 4, 2019, 8:23:07 AM10/4/19
to jenkinsc...@googlegroups.com
Jesse Glick started work on Bug JENKINS-50772
 
Change By: Jesse Glick
Status: Open In Progress

jglick@cloudbees.com (JIRA)

unread,
Oct 4, 2019, 8:23:08 AM10/4/19
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-50772
 
Re: Content type not set reasonably

Thanks! I will try to review soon.

o.v.nenashev@gmail.com (JIRA)

unread,
Oct 5, 2019, 9:20:04 PM10/5/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 8:26:03 AM10/6/19
to jenkinsc...@googlegroups.com
Change By: Jesse Glick
Resolution: Fixed
Status: Resolved In Review

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 8:26:04 AM10/6/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jan 7, 2020, 5:53:03 PM1/7/20
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Jesse Glick
 
Change By: Jesse Glick
Assignee: Robin Verduijn Jesse Glick

jglick@cloudbees.com (JIRA)

unread,
Jan 8, 2020, 1:04:06 PM1/8/20
to jenkinsc...@googlegroups.com
Change By: Jesse Glick
Status: In Review Fixed but Unreleased
Resolution: Fixed
Released As: 4 1 . 5.10-2.0 8

jglick@cloudbees.com (JIRA)

unread,
Jan 9, 2020, 1:01:03 PM1/9/20
to jenkinsc...@googlegroups.com
Change By: Jesse Glick
Status: Fixed but Unreleased Resolved
Reply all
Reply to author
Forward
0 new messages