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

Serve documents with the correct mime type when using a non-local storage backend #1416

Closed
nilssolanki opened this issue Jun 17, 2015 · 4 comments

Comments

@nilssolanki
Copy link

In my models, I have a wagtaildocs.Document field:

svg_mask = models.ForeignKey(
    verbose_name=u"Mask (SVG)",
    to='wagtaildocs.Document',
    null=True,
    blank=True,
    on_delete=models.SET_NULL,
    related_name='+'
)

I would like to serve an svg as an image/svg+xml, not as a stream, when accessing it via its URL. So far, I got the following advice (#1415 (comment)):

The streaming behaviour isn't dictated by the mime type.
You can switch it off globally though by installing django-sendfile and adding the following to your settings:
SENDFILE_BACKEND = 'sendfile.backends.simple'

Unfortunately, this did not seem to prevent the streaming. Do you know how I could save this?

@gasman
Copy link
Collaborator

gasman commented Jun 17, 2015

Several layers of confusion here, sorry!

"Serving as a stream" means something different to us - for us, it means the response is generated in stages, rather than being constructed in memory up front. You're talking about the mime type application/octet-stream, which is unrelated to that behaviour.

We made several changes to document serving in 1.0b2, including serving them with the correct mime type - however, we've now discovered that these changes are incompatible with remote storage backends such as storages.backends.s3boto.S3BotoStorage. This causes the error you saw in #1415. For now, I've fixed this (in #1417) so that these backends receive the old (1.0b1) behaviour, including the application/octet-stream mime type. We'll try to come up with an improved fix in Wagtail 1.1, so that remote backends use the correct mime type too.

@gasman gasman added this to the 1.1 milestone Jun 17, 2015
@gasman gasman changed the title wagtaildocs.Document: Disable streaming on url access Serve documents with the correct mime type when using a non-local storage backend Jun 17, 2015
@nilssolanki
Copy link
Author

Oh I see :) That makes sense, thank you.

@gasman
Copy link
Collaborator

gasman commented Sep 23, 2015

Will be addressed by #1420

@gasman gasman modified the milestones: 1.2, 1.1 Sep 23, 2015
@gasman gasman modified the milestones: 1.3, 1.2 Oct 26, 2015
@gasman gasman modified the milestones: 1.4, 1.3 Dec 15, 2015
@gasman gasman removed this from the 1.4 milestone Mar 1, 2016
anshumanf pushed a commit to anshumanf/wagtail that referenced this issue Jan 2, 2019
anshumanf pushed a commit to anshumanf/wagtail that referenced this issue May 21, 2019
  Fixes for documents implementation
  Github issues wagtail#3629 and wagtail#1416
anshumanf pushed a commit to anshumanf/wagtail that referenced this issue May 21, 2019
  Fixes for documents implementation
  Github issues wagtail#3629 and wagtail#1416
anshumanf pushed a commit to anshumanf/wagtail that referenced this issue May 21, 2019
  Fixes for documents implementation
  Github issues wagtail#3629 and wagtail#1416
@gasman
Copy link
Collaborator

gasman commented Mar 30, 2023

Completed in #5296 (which changed the default behaviour of remote storage backends to redirect to the remote URL rather than proxying through Django, meaning that headers are whatever the storage service sends).

@gasman gasman closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants