Looking at that code for RangedFileResponse, I'm kind of skeptical that it properly implements the Range header. Try removing that bit and see if it works.
Have you tried the download with various browsers? I wonder if Safari or Chrome released at the same time as the M1 chips is causing different Range header behavior than that code is designed to handle. So it might not be the M1 chip, but just an unrelated change in browser software that got pushed out at the same time. Speculating here. On Mon, Dec 21, 2020 at 3:19 PM Benjamin Schollnick < bscholln...@schollnick.net> wrote: > Folks, > > I’m using django for an online gallery application, and I’ve seen some > weird results since switching over to the M1 Mac Mini. > (Please note, I am running it under Rosetta / Intel Translation, since > pillow doesn’t seem to build under M1 native). > > So this could be a quirk of Rosetta, Django, or some combination of these. > > I don’t think so, but it could be. > > *So What is happening? * > > I never saw this under my 2013 intel iMac, but now under M1 (even under > Rosetta 2 / Intel translation) I am receiving a damaged / altered download > file roughly 6 out of 8 or 9 times (~25-33% successful). > > Just retrying the download will eventually be successful. > > This isn’t Pillow related, since the file is just being downloaded > directly (no thumbnails or alterations to the file is occurring). > > Does anyone have a suggestion on what to do at this time? I’m uncertain > on where to start to dig. Although removing ranged_response, might be a > starting point… > > URLs: > path("download/<uuid:d_uuid>", frontend.views.new_download, > name="downloads"), > path('thumbnails/<uuid:t_url_name>', frontend.views.thumbnails, > name="raw thumbnails"), > > > First, I am using these function for all graphics and/or file(s) being > sent: > > def new_download(request, d_uuid=None): > page = request.GET.get('page', None) > if page is None: > download = index_data.objects.filter(uuid=d_uuid, > ignore=False, > delete_pending=False)[0] > else: > print ("Attempting to find page %s in archive" % page) > print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(), > download.name)) > return respond_as_inline(request, > "%s%s%s" % ( > > configdata["locations"]["albums_path"], > os.sep, > download.fqpndirectory), > download.name) > > > def respond_as_inline(request, file_path, original_filename, ranged=False): > # https://stackoverflow.com/questions/36392510/django-download-a-file > # > https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari > # > https://stackoverflow.com/questions/720419/how-can-i-find-out-whether-a-server-supports-the-range-header > filename = os.path.join(file_path, original_filename) > if os.path.exists(filename): > mtype, encoding = mimetypes.guess_type(original_filename) > if mtype is None: > mtype = 'application/octet-stream' > response = RangedFileResponse(request, file=open(filename, 'rb'), > as_attachment=False, filename=os.path.basename(filename)) > response["Content-Type"] = mtype > return response > raise Http404 > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/75E15498-69D8-47B5-94D2-821C6B35CA92%40schollnick.net > <https://groups.google.com/d/msgid/django-users/75E15498-69D8-47B5-94D2-821C6B35CA92%40schollnick.net?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxWgXyHODdqsD%3DCzawv9D08zSPEwfUWda54kG%2B5XrHZmLA%40mail.gmail.com.