Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件POST上传 #11

Open
Cjiio opened this issue Mar 6, 2021 · 3 comments
Open

文件POST上传 #11

Cjiio opened this issue Mar 6, 2021 · 3 comments

Comments

@Cjiio
Copy link

Cjiio commented Mar 6, 2021

貌似好像不支持自定义文件后缀的上传,如.wld,上传报错空指针

@kongzue
Copy link
Owner

kongzue commented Mar 6, 2021

请确认该格式存在正确的MIME,因为post上传是需要获取到MIME type的,这个过程默认由BaseOkHttpV3代理获取,但若不是已知的MIME则可能出现问题

@Cjiio
Copy link
Author

Cjiio commented Mar 6, 2021

非已知MIME,为自定义后缀,请问如何解决

@Cjiio
Copy link
Author

Cjiio commented Mar 7, 2021

    public static String getMimeType(File file) {
        String suffix = getSuffix(file);
        if (suffix == null) {
            return "file/*";
        }
        String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix);
        if (type != null || !type.isEmpty()) {
            return type;
        }
        return "file/*";
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants