1、首先使用请求工具测试一下自己网络是否有问题 aS5CfKr07L5zWtS4lLRbsniG3CEXadUg2Unqe5CHpjo=
2、如果没问题,但是依然报错,那么使用 Apache HttpUtils 试试
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
3、对应方法修改 8fu8cDJmfdpbl/kjna5xbFRq8brk2wHoCLXGDPF6jqA=
public CreateOutPaintingTaskResponse createOutPaintingTask(CreateOutPaintingTaskRequest createOutPaintingTaskRequest) {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(CREATE_OUT_PAINTING_TASK_URL);
httpPost.addHeader("X-DashScope-Async", "enable");
httpPost.addHeader("Authorization", "Bearer " + apiKey);
httpPost.addHeader("Content-Type", "application/json");
StringEntity entity = new StringEntity(JSONUtil.toJsonStr(createOutPaintingTaskRequest), "UTF-8");
httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
if (response.getStatusLine().getStatusCode() != 200) {
log.error("请求异常:{}", responseBody);
throw new BusinessException(ErrorCode.OPERATION_ERROR, "AI 扩图失败");
}
CreateOutPaintingTaskResponse paintingResponse = JSONUtil.toBean(responseBody, CreateOutPaintingTaskResponse.class);
String errorCode = paintingResponse.getCode();
if (StrUtil.isNotBlank(errorCode)) {
String errorMessage = paintingResponse.getMessage();
log.error("AI 扩图失败,errorCode:{}, errorMessage:{}", errorCode, errorMessage);
throw new BusinessException(ErrorCode.OPERATION_ERROR, "AI 扩图接口响应异常");
}
return paintingResponse;
} catch (IOException e) {
log.error("创建扩图任务时发生错误", e);
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "系统错误,请稍后再试");
}
}
Auth sign header must include Pic-Operations (Status Code: 403; Error Code: AccessDeniedaS5CfKr07L5zWtS4lLRbsniG3CEXadUg2Unqe5CHpjo=
上传图片不报错但是添加 operation 操作报错
解决:切换到下面这个版本的依赖
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api</artifactId>
<version>5.6.227</version>
</dependency>
确认腾讯云的 数据万象服务 是否开启
用无痕窗口测试这样可以避免因为缓存不能及时看到结果
1、首先确保 COS 设置的是公有读写 https://console.cloud.tencent.com/cos/bucket
2、确保允许前端跨域请求(服务器同理)
没有的话添加一个 aS5CfKr07L5zWtS4lLRbsniG3CEXadUg2Unqe5CHpjo=
3、如果还是访问不了,那就在 COS 里面找到对应的图片
获取图片对象地址,复制到无痕浏览器访问试试,正常只要是公有读是可以正常访问的
批量抓取图片可能会没有后缀,但是不影响正常访问的,只要复制这个对象地址正确 ud2lbaaQgA7asbuFx2zyocayHo3nTFq9mWD3LwoaYCg= 就可以正常访问的!hh8kZr5oIIWSNoQ431Z2is4P7tu+SuQnXPZz37lHT1E=
4、还是不行?
确保自己配置文件 host 基本格式是 https://xxx.cos.ap-xxxx.myqcloud.com 同时确保其他配置是否正确
解决:禁用 JRebel 这类热加载插件即可 meP/WqR3MNkD1e0lYI0pAe/471MZOw9VR3IEl1E79H4=
解决:使用 Node >= 18 即可
推荐使用 NVM 进行管理 node 版本 安装教程
检查 router.ts 对应的 path 是否书写
HjpOe/rdEcCehdPVL1u7j0N2XeKJoa/vakFU+1wtsMo=