Giter Site home page Giter Site logo

Comments (5)

cooperlees avatar cooperlees commented on June 8, 2024 2

Ahh, it seems if it is set @ upload / write time, then this is indeed a bandersnatch bug. Nice find.

I'm asking on the issue if there are plans for a friendlier API and how do we edit existing files ContentType ...

from bandersnatch.

cooperlees avatar cooperlees commented on June 8, 2024

This is definitely a serving configuration issue. You need to make the Content-Type: s3 HTML headers send text/html if you're serving a index.html or application/vnd.pypi.simple.v1+json if you're seeing the json file to make pip happy ...

My quick search (linked above) says there is no default and you're somehow sending Content-Type: binary/octet-stream. So correcting that should help fix the issue.

I'm happy to take documentation updates to https://bandersnatch.readthedocs.io/en/latest/storage_options.html#amazon-s3 - Source file if you feel our docs are lacking. I've sadly never setup a S3 based mirror so can not help much more here.

from bandersnatch.

cs1jmc avatar cs1jmc commented on June 8, 2024

I've taken a second look at things with a fresh pair of eyes. Think you pointed in the right direction with the Content-Type.

From what I can tell the bandersnatch s3 plugin isn't specifying a Mime type when doing a PutObject to S3, which results in AWS giving the object the default of binary/octet-stream:

aws s3api head-object --bucket <bucketname> --key web/simple/index.html
{
    "AcceptRanges": "bytes",
    "LastModified": "2023-11-27T12:24:18+00:00",
    "ContentLength": 422,
    "ETag": omitted,
    "ContentType": "binary/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

From some surface level digging it looks like S3Path is being used to get the files to S3 and there's conversation about passing the Content-Type as a parameter in an existing issue:

liormizr/s3path#83 (comment)

I sadly lack the talent and knowledge on bandersnatch to know how to go about fixing things. (If what I mention sounds right)

from bandersnatch.

LeoQuote avatar LeoQuote commented on June 8, 2024

You can use a CDN to provide service, which could be cheaper and content-type can also be changed

Use https://github.com/pottava/aws-s3-proxy and nginx to set content-type if you're using this for internal use only.

from bandersnatch.

inthecloud247 avatar inthecloud247 commented on June 8, 2024

I also encountered this bug in the s3 server... until it's fixed I had to do a recursive fix of the content-types of the index.html pages in my bucket:

aws s3 cp \
       s3://MY_BUCKET/data/web/simple/ \
       s3://MY_BUCKET/data/web/simple/ \
       --exclude '*' \
       --include '*.html' \
       --no-guess-mime-type \
       --content-type="text/html" \
       --metadata-directive="REPLACE" \
       --recursive

from bandersnatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.