Skip to content

Commit b62237c

Browse files
storage interface add minio
1 parent 9d6fc85 commit b62237c

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

internal/common/minio.go

-4
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ func (m *Minio) upload(filePath, fileType string, onProgressFun func(int)) (stri
6666
}
6767
// fake callback
6868
onProgressFun(100)
69-
reqParams := make(url.Values)
70-
log.NewInfo("", reqParams)
71-
7269
presignedURL := endPoint.String() + "/" + minioResp.BucketName + "/" + newName
73-
log.NewInfo("", presignedURL)
7470
return presignedURL, newName, nil
7571
}
7672

internal/login/init_login.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package login
22

33
import (
4-
"errors"
54
comm2 "open_im_sdk/internal/common"
65
conv "open_im_sdk/internal/conversation_msg"
76
"open_im_sdk/internal/friend"
@@ -138,15 +137,21 @@ func (u *LoginMgr) login(userID, token string, cb open_im_sdk_callback.Base, ope
138137
u.group.SetGroupListener(u.groupListener)
139138

140139
u.full = full.NewFull(u.user, u.friend, u.group)
141-
if u.imConfig.ObjectStorage != "cos" && u.imConfig.ObjectStorage != "" {
142-
err = errors.New("u.imConfig.ObjectStorage failed ")
143-
common.CheckConfigErrCallback(cb, err, operationID)
144-
}
140+
//if u.imConfig.ObjectStorage != "cos" && u.imConfig.ObjectStorage != "" {
141+
// err = errors.New("u.imConfig.ObjectStorage failed ")
142+
// common.CheckConfigErrCallback(cb, err, operationID)
143+
//}
145144
log.NewInfo(operationID, u.imConfig.ObjectStorage)
146145
u.forcedSynchronization()
147146
log.Info(operationID, "forcedSynchronization success...")
148147
log.NewInfo(operationID, u.imConfig.ObjectStorage)
149-
objStorage := comm2.NewCOS(p)
148+
var objStorage comm2.ObjectStorage
149+
switch u.imConfig.ObjectStorage {
150+
case "cos":
151+
objStorage = comm2.NewCOS(p)
152+
case "minio":
153+
objStorage = comm2.NewMinio(p)
154+
}
150155
u.conversation = conv.NewConversation(u.ws, u.db, p, u.conversationCh,
151156
u.loginUserID, u.imConfig.Platform, u.imConfig.DataDir,
152157
u.friend, u.group, u.user, objStorage, u.conversationListener, u.advancedMsgListener)

main/main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121

2222
func main() {
2323

24-
//strMyUidx := "13900000000"
24+
strMyUidx := "13900000000"
2525
//friendUserID := "openIM2222"
26-
//tokenx := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiIxMzkwMDAwMDAwMCIsIlBsYXRmb3JtIjoiSU9TIiwiZXhwIjoxNjQ1ODYyMzIzLCJuYmYiOjE2NDUyNTc1MjMsImlhdCI6MTY0NTI1NzUyM30.TsrIgtKZhnbAUjjGFNnJvdzVQECLIaIJy_bvfRlNF4k"
27-
//test.InOutDoTest(strMyUidx, tokenx, WSADDR, APIADDR)
26+
tokenx := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiIxMzkwMDAwMDAwMCIsIlBsYXRmb3JtIjoiSU9TIiwiZXhwIjoxOTYwNzk0Mjg0LCJuYmYiOjE2NDU0MzQyODQsImlhdCI6MTY0NTQzNDI4NH0.pchFgEhL6vaYirWuAbMnVTcrQTk552i50_SWXlOHbuo"
27+
test.InOutDoTest(strMyUidx, tokenx, WSADDR, APIADDR)
2828
//tokenx := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiIxODY2NjY2MjQxMiIsIlBsYXRmb3JtIjoiSU9TIiwiZXhwIjoxNjQ1Njg5NjU3LCJuYmYiOjE2NDUwODQ4NTcsImlhdCI6MTY0NTA4NDg1N30.nV3cIcvaRjyUEay8G7UMe5LzKeNi6UenET1RXDT4Nao"
2929
//test.InOutDoTest(strMyUidx, tokenx, WSADDR, APIADDR)
3030
//test.DoTestCreateGroup()
@@ -41,7 +41,7 @@ func main() {
4141

4242
// test.DoSetGroupInfo()
4343
//test.DotestGetGroupMemberList()
44-
test.DotestMinio()
44+
//test.DotestMinio()
4545
//test.DotestKickGroupMember()
4646
// test.DotestInviteUserToGroup()
4747
//test.DotestGetGroupApplicationList()

test/t_group_sdk.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,24 @@ func test(storage common.ObjectStorage, callback baseCallback) {
273273
// }
274274
//})
275275
//log.NewInfo("0", dir, newName, err)
276-
dir, newName, err := storage.UploadImage("C:\\Users\\Administrator\\Desktop\\1.jpg", func(progress int) {
277-
if progress == 100 {
278-
callback.OnSuccess("")
279-
}
280-
})
281-
log.NewInfo("0", dir, newName, err, err)
282-
//dir, newName, err = storage.UploadSound("./main/main.go", func(progress int) {
276+
//dir, newName, err = storage.UploadImage("C:\\Users\\Administrator\\Desktop\\1.jpg", func(progress int) {
283277
// if progress == 100 {
284278
// callback.OnSuccess("")
285279
// }
286280
//})
287281
//log.NewInfo("0", dir, newName, err, err)
288-
//snapshotURL, snapshotUUID, videoURL, videoUUID, err := storage.UploadVideo("./main/main.go", "", func(progress int) {
282+
//dir, newName, err = storage.UploadSound("./main/main.go", func(progress int) {
289283
// if progress == 100 {
290284
// callback.OnSuccess("")
291285
// }
292286
//})
293-
//log.NewInfo(snapshotURL, snapshotUUID, videoURL, videoUUID, err)
287+
//log.NewInfo("0", dir, newName, err, err)
288+
snapshotURL, snapshotUUID, videoURL, videoUUID, err := storage.UploadVideo("./main/main.go", "C:\\Users\\Administrator\\Desktop\\1.jpg", func(progress int) {
289+
if progress == 100 {
290+
callback.OnSuccess("")
291+
}
292+
})
293+
log.NewInfo(snapshotURL, snapshotUUID, videoURL, videoUUID, err)
294294
}
295295

296296
type testGetGroupMembersInfo struct {

0 commit comments

Comments
 (0)