Details

    • Similar Issues:
    • Released As:
      1.8

      Description

      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.

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            Hide
            jglick Jesse Glick added a comment -

            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.

            Show
            jglick Jesse Glick added a comment - 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.
            Hide
            akdor1154 Jarrad Whitaker added a comment -

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

            Show
            akdor1154 Jarrad Whitaker added a comment - RobustHttpClient.uploadFile also has no way of setting a content type, which is another blocker for this I think?
            Hide
            akdor1154 Jarrad Whitaker added a comment - - edited

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

            Show
            akdor1154 Jarrad Whitaker added a comment - - edited (this is actually a blocker for our team to use this plugin, "I can't see my test report when I click the link ")
            Hide
            jglick Jesse Glick added a comment -

            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?

            Show
            jglick Jesse Glick added a comment - 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?
            Show
            akdor1154 Jarrad Whitaker added a comment - - edited Unless I'm reading wrong, by https://github.com/jenkinsci/artifact-manager-s3-plugin/blob/master/src/main/java/io/jenkins/plugins/artifact_manager_jclouds/JCloudsArtifactManager.java#L115 and https://github.com/jenkinsci/artifact-manager-s3-plugin/blob/master/src/main/java/io/jenkins/plugins/artifact_manager_jclouds/JCloudsArtifactManager.java#L134, it works by getting a presigned S3 url and `uploadFile`ing to it with RobustHttpClient.
            Hide
            dcurrie David Currie added a comment -

            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.

            Show
            dcurrie David Currie added a comment - 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.
            Hide
            jglick Jesse Glick added a comment -

            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.)

            Show
            jglick Jesse Glick added a comment - 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 Jesse Glick made changes -
            Field Original Value New Value
            Component/s apache-httpcomponents-client-4-api-plugin [ 23052 ]
            nanonyme Seppo Yli-Olli made changes -
            Link This issue duplicates JENKINS-57409 [ JENKINS-57409 ]
            Hide
            nanonyme Seppo Yli-Olli added a comment - - edited

            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.

            Show
            nanonyme Seppo Yli-Olli added a comment - - edited 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.
            Hide
            rverduijn Robin Verduijn added a comment -

            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.

            Show
            rverduijn Robin Verduijn added a comment - 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:   https://github.com/jenkinsci/apache-httpcomponents-client-4-api-plugin/pull/24 https://github.com/jenkinsci/artifact-manager-s3-plugin/pull/100   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.
            jglick Jesse Glick made changes -
            Assignee Robin Verduijn [ rverduijn ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            Hide
            jglick Jesse Glick added a comment -

            Thanks! I will try to review soon.

            Show
            jglick Jesse Glick added a comment - Thanks! I will try to review soon.
            Show
            oleg_nenashev Oleg Nenashev added a comment - Released in  https://github.com/jenkinsci/apache-httpcomponents-client-4-api-plugin/releases/tag/apache-httpcomponents-client-4-api-4.5.10-2.0
            oleg_nenashev Oleg Nenashev made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Released As 4.5.10-2.0
            jglick Jesse Glick made changes -
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] In Review [ 10005 ]
            Hide
            jglick Jesse Glick added a comment -

            No Oleg Nenashev that was just an API.

            Show
            jglick Jesse Glick added a comment - No Oleg Nenashev that was just an API.
            jglick Jesse Glick made changes -
            Remote Link This issue links to "artifact-manager-s3 #100 (Web Link)" [ 24239 ]
            jglick Jesse Glick made changes -
            Assignee Robin Verduijn [ rverduijn ] Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "artifact-manager-s3 #107 (Web Link)" [ 24241 ]
            jglick Jesse Glick made changes -
            Status In Review [ 10005 ] Fixed but Unreleased [ 10203 ]
            Resolution Fixed [ 1 ]
            Released As 4.5.10-2.0 1.8
            jglick Jesse Glick made changes -
            Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                6 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: