GXT 中的文件上传会歧视某些文件类型

发布于 2024-08-31 18:32:40 字数 1073 浏览 3 评论 0原文

我们正在使用 GXT (EXT + GWT) 和 Apache commons 文件上传 servlet 实用程序。我们可以上传文件,但某些类型的文件无法上传,例如文本文件。即使文本文件的扩展名已更改,它们仍然不会上传。

在 FileUploadBase.parseRequest 方法中,这似乎是跳过输入流复制到文件系统的代码。当我断点文本文件的上传时,我尝试将 iter.hasNext() 代码加粗,该代码会跳过stream.copy 代码行。

任何建议将不胜感激!

提前致谢。

    public List /* FileItem */ parseRequest(RequestContext ctx)
        throws FileUploadException {
    try {
        FileItemIterator **iter = getItemIterator(ctx)**;
        List items = new ArrayList();
        FileItemFactory fac = getFileItemFactory();
        if (fac == null) {
            throw new NullPointerException(
                "No FileItemFactory has been set.");
        }
        while (**iter.hasNext()**) {
            FileItemStream item = iter.next();
            FileItem fileItem = fac.createItem(item.getFieldName(),
                    item.getContentType(), item.isFormField(),
                    item.getName());
            try {
                Streams.copy(item.openStream(), fileItem.getOutputStream(),
                        true);
...

We are using GXT (EXT + GWT) and Apache commons file upload servlet utility. We have file uploads working but certain types are not uploaded, e.g., text files. Even if the text files have their extension changed they are still not uploaded.

In the FileUploadBase.parseRequest method this is the code that seems to be found to skip the input stream from being copied to the file system. I tried to bold the iter.hasNext() code that skips the stream.copy line of code when I break point the upload for a text file.

Any advice would be appreciated!

Thanks in advance.

    public List /* FileItem */ parseRequest(RequestContext ctx)
        throws FileUploadException {
    try {
        FileItemIterator **iter = getItemIterator(ctx)**;
        List items = new ArrayList();
        FileItemFactory fac = getFileItemFactory();
        if (fac == null) {
            throw new NullPointerException(
                "No FileItemFactory has been set.");
        }
        while (**iter.hasNext()**) {
            FileItemStream item = iter.next();
            FileItem fileItem = fac.createItem(item.getFieldName(),
                    item.getContentType(), item.isFormField(),
                    item.getName());
            try {
                Streams.copy(item.openStream(), fileItem.getOutputStream(),
                        true);
...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心凉 2024-09-07 18:32:40

这不会回答你的问题,但我可以发现有用的关于在 GWT 中上传文件的好库
GWTUpload 是一个用于将文件上传到 Web 服务器的库,显示进度条,其中包含有关进程的真实信息(文件大小、传输的字节数等)。它使用 ajax 请求向 Web 服务器询问上传进度。它有两个用 java 编写的组件,带有 servlet 和实用程序类的服务器端,以及使用 gwt 编译为 javascript 的客户端。 此处

This will not answer you question but I can find useful to tell about a good library for uploading files in GWT
GWTUpload is a library for uploading files to web servers, showing a progress bar with real information about the process (file size, bytes transferred, etc). It uses ajax requests to ask the web server for the upload progress. It has two components written in java, the server side with servlet and utility classes, and the client side that is compiled into javascript using gwt. here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文