mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2026-01-15 07:03:27 +08:00
Merge pull request #6 from longjuan/dev
fix MediaType is always application/octet and delete the unimplemented function of restriction extensions
This commit is contained in:
@@ -1 +1 @@
|
||||
version=1.1.0-SNAPSHOT
|
||||
version=1.1.1-SNAPSHOT
|
||||
|
||||
@@ -14,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.pf4j.Extension;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MediaTypeFactory;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
import reactor.core.Exceptions;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -148,7 +150,8 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
||||
return Mono.fromCallable(() -> {
|
||||
var client = buildOsClient(properties);
|
||||
// build object name
|
||||
var objectName = properties.getObjectName(uploadContext.file().filename());
|
||||
var originFilename = uploadContext.file().filename();
|
||||
var objectName = properties.getObjectName(originFilename);
|
||||
|
||||
var pos = new PipedOutputStream();
|
||||
var pis = new PipedInputStream(pos);
|
||||
@@ -163,12 +166,14 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
||||
}).subscribe(DataBufferUtils.releaseConsumer());
|
||||
|
||||
final var bucket = properties.getBucket();
|
||||
log.info("Uploading {} into S3ObjectStorage {}/{}/{}", uploadContext.file().filename(),
|
||||
var metadata = new ObjectMetadata();
|
||||
var contentType = MediaTypeFactory.getMediaType(originFilename)
|
||||
.orElse(MediaType.APPLICATION_OCTET_STREAM).toString();
|
||||
metadata.setContentType(contentType);
|
||||
var request = new PutObjectRequest(bucket, objectName, pis, metadata);
|
||||
log.info("Uploading {} into S3ObjectStorage {}/{}/{}", originFilename,
|
||||
properties.getEndpoint(), bucket, objectName);
|
||||
|
||||
var request = new PutObjectRequest(bucket, objectName, pis,
|
||||
new ObjectMetadata());
|
||||
|
||||
return ossExecute(() -> {
|
||||
var result = client.putObject(request);
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
@@ -28,7 +28,6 @@ class S3OsProperties {
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
private String allowExtensions;
|
||||
|
||||
private String region = "Auto";
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ spec:
|
||||
name: endpoint
|
||||
label: EndPoint
|
||||
validation: required
|
||||
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
|
||||
- $formkit: password
|
||||
name: accessKey
|
||||
label: Access Key
|
||||
@@ -62,7 +63,3 @@ spec:
|
||||
label: 绑定域名(CDN域名)
|
||||
placeholder: 如不设置,那么将使用 Bucket + EndPoint 作为域名
|
||||
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
|
||||
- $formkit: textarea
|
||||
name: allow_extensions
|
||||
label: 允许上传的文件类型
|
||||
placeholder: 使用半角逗号分隔
|
||||
|
||||
@@ -4,7 +4,7 @@ metadata:
|
||||
name: PluginS3ObjectStorage
|
||||
spec:
|
||||
enabled: true
|
||||
version: 1.1.0
|
||||
version: 1.1.1
|
||||
requires: ">=2.0.0"
|
||||
author:
|
||||
name: longjuan
|
||||
|
||||
Reference in New Issue
Block a user