|
|
@@ -13,12 +13,15 @@ import com.github.jfcloud.excel.editor.docdeal.oss.OssProperties;
|
|
|
import com.github.jfcloud.excel.editor.docdeal.oss.service.OssTemplate;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.MediaTypeFactory;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@Slf4j
|
|
|
@Controller
|
|
|
@@ -83,9 +86,16 @@ public class FileController {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
response.setContentLength((int) s3Object.getObjectMetadata().getContentLength());
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename*=utf8''" + URLEncodeUtil.encode(name));
|
|
|
+
|
|
|
+ String type = "attachment";
|
|
|
+ Optional<MediaType> opt = MediaTypeFactory.getMediaType(name);
|
|
|
+ if (opt.isPresent()) {
|
|
|
+ MediaType mediaType = opt.get();
|
|
|
+ response.setContentType(mediaType.toString());
|
|
|
+ type = "inline";
|
|
|
+ }
|
|
|
+ response.setHeader("Content-Disposition", type + ";filename*=utf8''" + URLEncodeUtil.encode(name));
|
|
|
|
|
|
IoUtil.copy(s3Object.getObjectContent(), response.getOutputStream());
|
|
|
} catch (IOException e) {
|