MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    发送文件时不能出现字符 ":"

    开发交流
    2
    2
    96
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lngex
      lngex last edited by lngex

      我在Windows上运行的程序,所以在文件路径上必有 “:”,如
      C:;请问有没有什么办法解决

          /**
           * 发送视频文件
           * @param group 群
           * @param url 视频超链接
           * @return 当前消息链
           */
          public Msg video(Group group, String url) {
              File file = new File("E:\\bot\\video", System.currentTimeMillis() + ".mp4");
              // 下载文件到file
              HttpClientUtils.getFile(url,file);
              this.messageChainBuilder.append(group.getFiles().uploadNewFile(file.getPath(),ExternalResource.create(file)).toMessage());
              return this;
          }
      

      错误信息:
      java.lang.IllegalArgumentException: Chars ':*?"<>|' are not allowed in path. RemoteFile path contains illegal char: ':'. path='E:\bot\video\1657074806337.mp4'

      1 Reply Last reply Reply Quote 0
      • Moved from BUG反馈 by  Karlatemp Karlatemp 
      • 4
        4Godsake last edited by

        uploadNewFile的方法的第一个参数是文件相对于群文件根目录/的位置

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact