diff options
author | Wim <wim@42.be> | 2021-12-12 00:05:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-12 00:05:15 +0100 |
commit | 3893a035be347a7687a41d2054dd1b274d3a0504 (patch) | |
tree | dfe4a3bf72a0a6356e51bd8fc2e88e9a26e52331 /vendor/github.com/SevereCloud/vksdk/v2/api/upload.go | |
parent | 658bdd9faa835660ae407331732e9d93d8f6443b (diff) | |
download | matterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.tar.gz matterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.tar.bz2 matterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.zip |
Update dependencies/vendor (#1659)
Diffstat (limited to 'vendor/github.com/SevereCloud/vksdk/v2/api/upload.go')
-rw-r--r-- | vendor/github.com/SevereCloud/vksdk/v2/api/upload.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/SevereCloud/vksdk/v2/api/upload.go b/vendor/github.com/SevereCloud/vksdk/v2/api/upload.go index 2c947c5d..59f65460 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/api/upload.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/api/upload.go @@ -959,3 +959,57 @@ func (vk *VK) UploadGroupImage(imageType string, file io.Reader) (response objec return } + +// UploadMarusiaPicture uploading picture. +// +// Limits: height not more than 600 px, +// aspect ratio of at least 2:1. +func (vk *VK) UploadMarusiaPicture(file io.Reader) (response MarusiaSavePictureResponse, err error) { + uploadServer, err := vk.MarusiaGetPictureUploadLink(nil) + if err != nil { + return + } + + bodyContent, err := vk.UploadFile(uploadServer.PictureUploadLink, file, "photo", "photo.jpg") + if err != nil { + return + } + + var handler object.MarusiaPictureUploadResponse + + err = json.Unmarshal(bodyContent, &handler) + if err != nil { + return + } + + photo, _ := json.Marshal(handler.Photo) + + response, err = vk.MarusiaSavePicture(Params{ + "server": handler.Server, + "photo": string(photo), + "hash": handler.Hash, + }) + + return +} + +// UploadMarusiaAudio uploading audio. +// +// https://vk.com/dev/marusia_skill_docs10 +func (vk *VK) UploadMarusiaAudio(file io.Reader) (response MarusiaCreateAudioResponse, err error) { + uploadServer, err := vk.MarusiaGetAudioUploadLink(nil) + if err != nil { + return + } + + bodyContent, err := vk.UploadFile(uploadServer.AudioUploadLink, file, "file", "audio.mp3") + if err != nil { + return + } + + response, err = vk.MarusiaCreateAudio(Params{ + "audio_meta": string(bodyContent), + }) + + return +} |