|
|
@@ -2,6 +2,7 @@ package cn.reghao.oss.console.app.rpc;
|
|
|
|
|
|
import cn.reghao.oss.console.app.model.dto.ObjectsScopeDto;
|
|
|
import cn.reghao.oss.console.app.model.po.StoreNode;
|
|
|
+import cn.reghao.oss.console.app.model.po.UploadChannel;
|
|
|
import cn.reghao.oss.console.app.service.UploadChannelService;
|
|
|
import cn.reghao.oss.console.util.AuthKeyContext;
|
|
|
import cn.reghao.oss.store.api.dto.ObjectInfo;
|
|
|
@@ -36,10 +37,23 @@ public class OssObjectService {
|
|
|
}
|
|
|
|
|
|
public void deleteByObjectUrl(String objectUrl) throws Exception {
|
|
|
- String objectName = objectUrl.replace("//", "");
|
|
|
- int channelId = 1;
|
|
|
- ObjectService objectService = getObjectService(channelId);
|
|
|
- objectService.deleteByObjectName(objectName);
|
|
|
+ int loginUser = AuthKeyContext.getUser();
|
|
|
+ String domain = objectUrl.replace("//", "").split("/")[0];
|
|
|
+ String objectName = objectUrl.replace("//" + domain + "/", "");
|
|
|
+ List<UploadChannel> uploadChannels = uploadChannelService.getByDomainAndCreateBy(domain, loginUser);
|
|
|
+ for (UploadChannel uploadChannel : uploadChannels) {
|
|
|
+ String prefix = uploadChannel.getPrefix();
|
|
|
+ // TODO get best match
|
|
|
+ if (objectName.startsWith(prefix)) {
|
|
|
+ int channelId = uploadChannel.getChannelId();
|
|
|
+ ObjectService objectService = getObjectService(channelId);
|
|
|
+ objectService.deleteByObjectName(objectName);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String errMsg = String.format("%s not associate with any channels", objectUrl);
|
|
|
+ throw new Exception(errMsg);
|
|
|
}
|
|
|
|
|
|
public String getSignedUrl(int channelId, String objectId) throws Exception {
|