上传文件到OSS报错:[Server]Unable to execute HTTP request: Position is not equal to file length

上传文件到OSS报错:

[Server]Unable to execute HTTP request: Position is not equal to file length

控制台报类似以下的错:

[ErrorCode]: PositionNotEqualToLength
[RequestId]: 603D07EA9ACC07383080C699
[HostId]: naiyi-course.oss-cn-shenzhen.aliyuncs.com
[ResponseError]:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>PositionNotEqualToLength</Code>
  <Message>Position is not equal to file length</Message>
  <RequestId>603D07EA9ACC07383080C699</RequestId>
  <HostId>xxx-xxxx.oss-cn-shenzhen.aliyuncs.com</HostId>
</Error>

27:40.004 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet]:175  Servlet.service() for servlet [dispatcherServlet] in context with path [/file] threw exception [Request processing failed; nested exception is com.aliyun.oss.OSSException: Position is not equal to file length

说明

其实报错很明显,我的代码未加判断,分片上传文件功能代码不够严谨。

解决

将OSS上的文件,先删掉,再重新执行即可。

上一篇:阿里云对象存储服务OSS概述笔记


下一篇:LeetCode 516. 最长回文子序列