Skip to content

微信多媒体文件没有后缀名时下载失败 #300

Closed
@xiaohe27

Description

@xiaohe27

对于用户发给企业微信的语音消息,在下载时得到的是一个没有后缀名的文件,文件名默认是“voice”。
这导致了wxCpService.mediaDownload(media_id) 这个默认的下载多媒体文件的接口抛出异常。

ApacheMediaDownloadRequestExecutor.java
文件中

  String fileName = getFileName(response);
  if (StringUtils.isBlank(fileName)) {
    return null;
  }

  String[] nameAndExt = fileName.split("\\.");
  return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], super.tmpDirFile);

会抛出ArrayIndexOfBoundsException

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions