新增阿里云OSS文件上传参数获取接口 (#115)

* configure update

* mongo:4.0

* open-im-server -> open_im_server

* sleep 15

* 0.0.0.0

* sleep 10 15

* Update config.yaml

* config

* Update docker-compose.yaml

* Update config.yaml

* Create ISSUE_TEMPLATE.md

* Update ISSUE_TEMPLATE.md

* Create ISSUE_TEMPLATE

* add issue template

* add issue template

* add issue template

* add issue template

* Update README.md

* script

* script

* script

* config

* script

* config update

* script update

* image: openim/open_im_server:v1.0.6

* script

* script

* script

* version update

* sender message sync

* version update

* 阿里云oss sts上传参数

* 阿里云oss sts上传参数

Co-authored-by: wenxu12345 <44203734@qq.com>
Co-authored-by: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Co-authored-by: Gordon <1432970085@qq.com>
Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
pull/189/head
hxnets 3 years ago committed by GitHub
parent e0c6972bed
commit 6c43f75f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,37 @@
---
name: 🐞 Bug
about: File a bug/issue
title: '[BUG] <title>'
labels: Bug, Needs Triage
assignees: ''
---
<!--
Note: Please search to see if an issue already exists for the bug you encountered.
-->
### Environment:
<!-- linux? windows? or Mac?
Example:
- OS: Ubuntu 20.04 -->
### Physical Memory Capacity:
<!-- 8G or above is better -->
### Docker Image:
<!-- Did you pull the docker image before execute docker images -->
### Code Version:
<!-- Did you pull code from github? Make sure the code is up to date-->
### Component installation:
<!-- Has etcd, mysql, mongodb, redis or Kafka been installed on the server before Open-IM-Server deployment-->
### Log File:
<!-- view log file(logs/openIM.log) content. -->
### screenshot:
<!---->

1
.gitignore vendored

@ -7,6 +7,7 @@ out-test
.github
.idea
deploy/open_im_demo
deploy/open_im_api
deploy/open_im_msg_gateway

@ -92,6 +92,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
4. Start docker-compose with one click(Docker automatically pulls all images)
```
cd Open-IM-Server
docker-compose up -d
```
@ -99,6 +100,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
```
./docker_check_service.sh
./check_all.sh
```
![OpenIMServersondockerpng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-docker.png)

@ -74,6 +74,7 @@ endpoints:
rpc_admin_cms: openim_rpc_admin_cms
rpc_message_cms: openim_rpc_admin_cms
api:
openImApiPort: [ 10000 ] #api服务端口默认即可需要开放此端口或做nginx转发
cmsapi:
@ -106,6 +107,7 @@ credential: #腾讯cos发送图片、视频、文件时需要请自行申
OssRoleArn: "acs:ram::xxx:role/xxx"
rpcport: #rpc服务端口 默认即可
openImUserPort: [ 10100 ]
openImFriendPort: [ 10200 ]
@ -511,3 +513,4 @@ demo:

@ -32,6 +32,7 @@ services:
# - MONGO_INITDB_ROOT_USERNAME=openIM
# - MONGO_INITDB_ROOT_PASSWORD=openIM
#TZ: Asia/Shanghai
restart: always

@ -298,12 +298,14 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=

@ -0,0 +1,72 @@
package apiThird
import (
"Open_IM/pkg/common/config"
"github.com/aliyun/alibaba-cloud-sdk-go/services/sts"
"github.com/gin-gonic/gin"
"net/http"
)
type paramsAliyunCloudStorageCredential struct {
Token string `form:"token"`
OperationID string `form:"operationID"`
}
func AliyunCloudStorageCredential(c *gin.Context) {
params := paramsAliyunCloudStorageCredential{}
if err := c.BindQuery(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Parameter parsing errorplease check the parameters and request service again"})
return
}
credential := config.Config.Credential.Aliyun
if credential.AccessKeyId == "" || credential.AccessKeySecret == "" || credential.Bucket == "" || credential.Region == "" || credential.RegionId == "" || credential.RoleArn == "" {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Aliyun OSS config error"})
return
}
//构建一个阿里云客户端, 用于发起请求。
//构建阿里云客户端时需要设置AccessKey ID和AccessKey Secret。
client, err := sts.NewClientWithAccessKey(credential.RegionId, credential.AccessKeyId, credential.AccessKeySecret)
//构建请求对象。
request := sts.CreateAssumeRoleRequest()
request.Scheme = "https"
type CredentialPolicyStatement struct {
Action []string `json:"action,omitempty"`
Effect string `json:"effect,omitempty"`
Resource []string `json:"resource,omitempty"`
Condition map[string]map[string]interface{} `json:"condition,omitempty"`
}
type CredentialPolicy struct {
Version string `json:"version,omitempty"`
Statement []CredentialPolicyStatement `json:"statement,omitempty"`
}
//设置参数。关于参数含义和设置方法请参见《API参考》。
request.RoleArn = credential.RoleArn
request.RoleSessionName = params.OperationID
request.Policy = "{\n \"Version\": \"1\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"oss:PutObject\"\n ],\n \"Resource\": \"acs:oss:*:*:*\"\n }\n ]\n}"
//request.DurationSeconds = "900"
//发起请求,并得到响应。
res, err := client.AssumeRole(request)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"errCode": config.ErrTencentCredential.ErrCode,
"errMsg": err.Error(),
"bucket": "",
"region": "",
"data": res,
})
return
}
c.JSON(http.StatusOK, gin.H{
"errCode": 0,
"errMsg": "",
"region": config.Config.Credential.Aliyun.Region,
"bucket": config.Config.Credential.Aliyun.Bucket,
"data": res,
})
}

@ -92,6 +92,17 @@ func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgRe
resp = append(resp, temp)
}
}
//Single chat sender synchronization message
if in.GetSessionType() == constant.SingleChatType {
userIDList = genUidPlatformArray(in.SendID)
for _, v := range userIDList {
UIDAndPID = strings.Split(v, " ")
if conn := ws.getUserConn(v); conn != nil {
_ = sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
}
}
}
if !tag {
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
}

@ -64,7 +64,6 @@ type config struct {
SecretAccessKey string `yaml:"secretAccessKey"`
} `yaml:"minio"`
}
Mysql struct {
DBAddress []string `yaml:"dbMysqlAddress"`
DBUserName string `yaml:"dbMysqlUserName"`

@ -0,0 +1,11 @@
#!/usr/bin/env bash
image=openim/open_im_server:v1.0.5
rm Open-IM-Server -rf
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
cd Open-IM-Server
git checkout tuoyun
cd cmd/Open-IM-SDK-Core/
git checkout tuoyun
cd ../../
docker build -t $image . -f deploy.Dockerfile
docker push $image

@ -8,3 +8,4 @@ sleep 30
echo "check OpenIM................................"
./check_all.sh

@ -61,6 +61,6 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 &
sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
# echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
done
done

Loading…
Cancel
Save