添加配置项,可以为内存文件存储添加远程服务地址
This commit is contained in:
@@ -183,6 +183,11 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
|
||||
# local media server configuration
|
||||
# 本地媒体服务器配置。
|
||||
local.media.storage.root media
|
||||
# 如果使用内置文件存储,文件上传后地址默认为 http://server.ip:http_port/fs/5/2021/03/27/08/filename。
|
||||
# 如果需要使用nginx添加https支持,请打开下面配置,这样客户端得到的文件地址为 https://example.com/media/fs/5/2021/03/27/08/filename。
|
||||
# 需要nginx把请求从https://example.com/media/fs 转到 http://server.ip:http_port/fs。注意需要带上所有header。
|
||||
# 尽管内置文件存储可以使用,但是我们还是建议使用专业级别的对象存储服务,社区版可以使用七牛,专业版另外支持阿里云和也是私有对象存储。详情请参考 https://docs.wildfirechat.cn/server/oss.html
|
||||
# local.media.storage.remote_server_url https://example.com/media
|
||||
|
||||
# 是否支持多端登陆,为true时支持任意平台任意多个客户端同时登录;为false时每个平台只支持一个端登录,但不同平台可以同时登录。
|
||||
server.multi_endpoint false
|
||||
|
||||
@@ -85,6 +85,8 @@ public final class BrokerConstants {
|
||||
public static final String QINIU_BUCKET_FAVORITE_DOMAIN = "qiniu.bucket_favorite_domain";
|
||||
|
||||
public static final String FILE_STORAGE_ROOT = "local.media.storage.root";
|
||||
public static final String FILE_STORAGE_REMOTE_SERVER_URL = "local.media.storage.remote_server_url";
|
||||
|
||||
public static final String USER_QINIU = "media.server.use_qiniu";
|
||||
|
||||
public static final String PUSH_ANDROID_SERVER_ADDRESS = "push.android.server.address";
|
||||
|
||||
@@ -10,12 +10,15 @@ package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.qiniu.util.Auth;
|
||||
import com.xiaoleilu.loServer.action.UploadFileAction;
|
||||
import io.moquette.server.config.MediaServerConfig;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import static io.moquette.server.config.MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL;
|
||||
|
||||
@Handler("GMUT")
|
||||
public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTokenRequest> {
|
||||
@Override
|
||||
@@ -80,8 +83,12 @@ public class GetMediaUploadTokenHandler extends IMHandler<WFCMessage.GetUploadTo
|
||||
resultBuilder.setPort(80);
|
||||
} else {
|
||||
token = UploadFileAction.getToken(type);
|
||||
resultBuilder.setDomain("http://" + MediaServerConfig.SERVER_IP + ":" + MediaServerConfig.HTTP_SERVER_PORT)
|
||||
.setServer(MediaServerConfig.SERVER_IP);
|
||||
if(StringUtil.isNullOrEmpty(MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL)) {
|
||||
resultBuilder.setDomain("http://" + MediaServerConfig.SERVER_IP + ":" + MediaServerConfig.HTTP_SERVER_PORT);
|
||||
} else {
|
||||
resultBuilder.setDomain(MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL);
|
||||
}
|
||||
resultBuilder.setServer(MediaServerConfig.SERVER_IP);
|
||||
resultBuilder.setPort(MediaServerConfig.HTTP_SERVER_PORT);
|
||||
}
|
||||
|
||||
|
||||
@@ -346,6 +346,7 @@ public class Server {
|
||||
file.mkdirs();
|
||||
}
|
||||
ServerSetting.setRoot(file);
|
||||
MediaServerConfig.FILE_STROAGE_REMOTE_SERVER_URL = config.getProperty(FILE_STORAGE_REMOTE_SERVER_URL);
|
||||
|
||||
MediaServerConfig.USER_QINIU = Integer.parseInt(config.getProperty(BrokerConstants.USER_QINIU)) > 0;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class MediaServerConfig {
|
||||
public static String SERVER_IP = "localhost";
|
||||
public static int HTTP_SERVER_PORT = 8080;
|
||||
public static String FILE_STROAGE_ROOT = "fs";
|
||||
public static String FILE_STROAGE_REMOTE_SERVER_URL;
|
||||
public static boolean USER_QINIU = false;
|
||||
|
||||
|
||||
|
||||
@@ -180,7 +180,11 @@ qiniu.bucket_favorite_domain http://cdn2.wildfirechat.cn
|
||||
# local media server configuration
|
||||
# 本地媒体服务器配置。
|
||||
local.media.storage.root ./media
|
||||
|
||||
# 如果使用内置文件存储,文件上传后地址默认为 http://server.ip:http_port/fs/5/2021/03/27/08/filename。
|
||||
# 如果需要使用nginx添加https支持,请打开下面配置,这样客户端得到的文件地址为 https://example.com/media/fs/5/2021/03/27/08/filename。
|
||||
# 需要nginx把请求从https://example.com/media/fs 转到 http://server.ip:http_port/fs。注意需要带上所有header。
|
||||
# 尽管内置文件存储可以使用,但是我们还是建议使用专业级别的对象存储服务,社区版可以使用七牛,专业版另外支持阿里云和也是私有对象存储。详情请参考 https://docs.wildfirechat.cn/server/oss.html
|
||||
# local.media.storage.remote_server_url https://example.com/media
|
||||
|
||||
# 是否支持多端登陆,为true时支持任意平台任意多个客户端同时登录;为false时每个平台只支持一个端登录,但不同平台可以同时登录。
|
||||
server.multi_endpoint false
|
||||
|
||||
Reference in New Issue
Block a user