简体   繁体   English

如何使用 Play 进行文件上传监控! 框架

[英]How to perform file upload monitoring with Play! framework

Is it possible to monitor file uploads, somehow, with Play?是否可以通过 Play 以某种方式监控文件上传? framework?框架? Also, if the file should be BIG (ie +500MB), would it be possible to save the received bytes into a temporary file instead of keeping it in memory?此外,如果文件应该很大(即 +500MB),是否可以将接收到的字节保存到临时文件中,而不是将其保存在 memory 中? (see update below) (见下面的更新)

note : there is no code to show as I'm wondering these questions and cannot seem to find the answers with Google注意:没有代码可以显示,因为我想知道这些问题并且似乎无法通过 Google 找到答案

Thanks!谢谢!

** Update ** **更新**

(I almost forgot about this question.) Well, apparantly, files uploaded are stored in temporary files, and the files are not passed as a byte array (or something), but as a Java File object to the action controller . (我几乎忘记了这个问题。)嗯,显然,上传文件存储在临时文件中,并且这些文件不是作为字节数组(或其他东西)传递的,而是作为Java File object 到动作 Z594C103F2C6E04EC39

But even in a RESTful environment, file monitoring can be achieved.但即使在 RESTful 环境中,可以实现文件监控。

** Update 2 ** **更新 2 **

Is there a way to get early event listeners on incoming HTTP requests?有没有办法在传入的 HTTP 请求中获取早期事件侦听器? This could allow for monitoring request data transfer.这可以允许监控请求数据传输。

Large requests and temp files大型请求和临时文件

Play.玩。 is already storing large HTTP requests in temp files named after UUIDs (thus reducing the memory footprint of the server), Once the request is done.已经在以 UUID 命名的临时文件中存储了大型 HTTP 请求(从而减少了服务器的 memory 占用空间),一旦请求完成。 this file gets deleted.该文件被删除。

Monitoring uploads in Play!在 Play 中监控上传!

Play!玩! is using (the awesome) Netty project for its HTTP server stack (and also on the client stack, if you're considering Async HTTP client .正在为其 HTTP 服务器堆栈(以及客户端堆栈,如果您正在考虑Async HTTP 客户端)使用(很棒的) Netty项目。

Netty is:网是:

  • asynchronous异步
  • event-driven事件驱动
  • 100% HTTP 100% HTTP

Given Play,'s stack, you should be able to implement your "upload progress bar" or something.给定 Play,的堆栈,您应该能够实现“上传进度条”或其他东西。 Actually, Async HTTP client already achieves progress listeners for file uplaods and resumable download (see the quick start guide ).实际上,Async HTTP 客户端已经实现了文件上传和可恢复下载进度侦听器(请参阅快速入门指南)。

But play.server package doesn't seem to provide such functionality/extension point.但是play.server package 似乎没有提供这样的功能/扩展点。

Monitoring uploads anyway无论如何监控上传

I think Play.我觉得玩。 is meant to be behind a "real" HTTP server in reverse proxy mode (like nginx or lighthttpd).意味着在反向代理模式(如 nginx 或 lighthttpd)的“真实”HTTP 服务器后面。

So you'd better off using an upload progress module for one of those servers (like HttpUploadProgressModule for nginx) than messing with Play.'s HTTP stack.因此,您最好为其中一台服务器使用上传进度模块(例如 nginx 的HttpUploadProgressModule ),而不是弄乱 Play. 的 HTTP 堆栈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM