From 3893a035be347a7687a41d2054dd1b274d3a0504 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 12 Dec 2021 00:05:15 +0100 Subject: Update dependencies/vendor (#1659) --- .../github.com/SevereCloud/vksdk/v2/api/upload.go | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'vendor/github.com/SevereCloud/vksdk/v2/api/upload.go') 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 +} -- cgit v1.2.3