zhaowenyu
2026-01-06 4e8a1c02b45f72f6377603778e8c8746ed82f374
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.ard.sample.storage.service.impl;
 
import com.ard.common.config.OssConfiguration;
import com.ard.sample.component.mqtt.model.*;
import com.ard.sample.component.mqtt.service.IMessageSenderService;
import com.ard.oss.model.StsCredentialsDTO;
import com.ard.sample.config.DockConfiguration;
import com.ard.sample.storage.service.IStorageService;
import com.ard.oss.service.impl.OssServiceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.MessageHeaders;
import org.springframework.stereotype.Service;
 
/**
 * @author sean
 * @version 0.3
 * @date 2022/3/9
 */
@Service
public class StorageServiceImpl implements IStorageService {
 
    @Autowired
    private IMessageSenderService messageSender;
 
    @Autowired
    private OssServiceContext ossService;
 
    @Override
    public StsCredentialsDTO getSTSCredentials() {
        return StsCredentialsDTO.builder()
                //机场媒体库minio配置信息用代理地址,桶用机场的桶。
                //.endpoint(OssConfiguration.endpoint)
                .endpoint(DockConfiguration.endpoint)
//                .bucket(OssConfiguration.bucket)
                .bucket(DockConfiguration.bucket)
                .credentials(ossService.getCredentials())
                .provider(OssConfiguration.provider)
                .objectKeyPrefix(OssConfiguration.objectDirPrefix)
                .region(OssConfiguration.region)
                .build();
    }
 
    @Override
    @ServiceActivator(inputChannel = ChannelName.INBOUND_REQUESTS_STORAGE_CONFIG_GET, outputChannel = ChannelName.OUTBOUND)
    public void replyConfigGet(CommonTopicReceiver receiver, MessageHeaders headers) {
        // 20251219 这里是获取上传临时凭证的接口,稍候分析下是否满足条件,如果可以的话就直接回复临时凭证即可
        CommonTopicResponse<RequestsReply> response = CommonTopicResponse.<RequestsReply>builder()
                .tid(receiver.getTid())
                .bid(receiver.getBid())
                .data(RequestsReply.success(this.getSTSCredentials()))
                .timestamp(System.currentTimeMillis())
                .method(RequestsMethodEnum.STORAGE_CONFIG_GET.getMethod())
                .build();
        messageSender.publish(headers.get(MqttHeaders.RECEIVED_TOPIC) + TopicConst._REPLY_SUF, response);
    }
}