用于大文件上传的 Java REST API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24031134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java REST API for Large file uploads
提问by User 99x
I'm developing a REST API using Jersey and I need to add large file uploading via REST API. I tried with small files and its working. However, the API will be used to upload large files which will have size of 2GB - 5GB, since it will be used to upload videos.
我正在使用 Jersey 开发 REST API,我需要通过 REST API 添加大文件上传。我尝试使用小文件及其工作。但是,该 API 将用于上传大小为 2GB - 5GB 的大文件,因为它将用于上传视频。
I have checked on the stack overflow and other forums to find similar questions and its been suggest to use streaming to upload large files. I'm not sure how to write the REST API to accept such large files without timeout. I want to use both REST API and also normal file upload (via html file upload) to accept large files. I want to know how I can break files into small chunks and upload to the REST API and store the files in the server.
我检查了堆栈溢出和其他论坛以找到类似的问题,并建议使用流来上传大文件。我不确定如何编写 REST API 来接受如此大的文件而不会超时。我想同时使用 REST API 和普通文件上传(通过 html 文件上传)来接受大文件。我想知道如何将文件分成小块并上传到 REST API 并将文件存储在服务器中。
Are there any libraries in Javascript and Java to make this task easy?
是否有任何 Javascript 和 Java 库可以使此任务变得容易?
回答by jeorfevre
Please take a look to this response stackoverflow : uploading large files with jersey(see the code of sikrip) that is similar to your problem. And here is an example JS client code for uploading large file.
请查看此响应stackoverflow :Uploading large files with jersey(see the code of sikrip) 与您的问题类似。这是一个用于上传大文件的示例JS 客户端代码。
I've been testing this JS code and that's working.
我一直在测试这个 JS 代码,它正在工作。
Enjoy!
享受!