|
|
|
@ -2,6 +2,7 @@ package com.bw.opai.file.service.impl; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
import org.apache.http.HttpEntity; |
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
@ -15,6 +16,7 @@ import org.apache.http.util.EntityUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
@ -55,13 +57,14 @@ public class FileServiceImpl implements FileService { |
|
|
|
|
|
|
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create(); |
|
|
|
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); |
|
|
|
|
|
|
|
|
|
|
|
String newFileName = UUID.randomUUID() + "." + StringUtils.getFilenameExtension(file.getOriginalFilename()); |
|
|
|
// 文件流 |
|
|
|
builder.addBinaryBody( |
|
|
|
"file", |
|
|
|
file.getInputStream(), |
|
|
|
ContentType.APPLICATION_OCTET_STREAM, |
|
|
|
file.getOriginalFilename() |
|
|
|
newFileName |
|
|
|
); |
|
|
|
// 👇 关键:要求 GoFast 返回 JSON |
|
|
|
builder.addTextBody("output", "json"); |
|
|
|
|