On Sat, Oct 17, 2020 at 12:06 AM Mike Orr <[email protected]> wrote: > > I'm migrating user-uploaded files from a local filesystem to MinIO (an > S3-compatible file server). I can't use FileResponse because I get > back a filehandle or a bytes, and I'd have to write it to a temporary > file to use FileResponse.I'm also exploring presigned URLs to have the > browser fetch the file, but right now I want to serve it server-side. > What Pyramid response args should I use, and how should I stream the > content? I looked at the source of FileResponse, and it creates an > 'app_iter' object using 'environ["wsgi.file_wrapper"]'. Do I have to > do all that? Or can I just do 'body_file=result["body"]', which is the > filehandle and has a 'read' method. What is 'wsgi.file_wrapper' > anyway?
Here's the documentation for the filehandle object: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/response.html There's an 'iter_chunks' method that yields fixed-size chunks of the file. So can I do 'app_iter=result["Body"].iter_chunks()' ? It looks like this is what FileResponse's app_iter code is trying to do. The default chunk size is 1KB, while FileResponse uses 256KB chunks. What size is best for this use case? -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3DuqWeizEOMtKeQq-PAZ10B-j-5frSaSEJ1YXBeWETQz0qQ%40mail.gmail.com.
