Skip to main content

messages.uploadMedia

Upload a file and associate it to a chat (without actually sending it to the chat) May also be used in a business connection, not by wrapping the query in invokeWithBusinessConnection », but rather by specifying the business connection ID in the business_connection_id parameter.

func (c *Client) MessagesUploadMedia(ctx context.Context, request *MessagesUploadMediaRequest) (MessageMediaClass, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesUploadMedia(ctx, &tg.MessagesUploadMediaRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // MessageMediaClass
return nil
})

Parameters

NameTypeRequiredDescription
BusinessConnectionIDstringWhether the media will be used only in the specified business connection », and not directly by the bot.
PeerInputPeerClassyesThe chat, can be inputPeerEmpty for bots and inputPeerSelf for users.
MediaInputMediaClassyesFile uploaded in chunks as described in files »

Returns

MessageMediaClass

Possible errors

CodeTypeDescription
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400CHAT_RESTRICTEDYou can't send messages in this chat, you were restricted.
403CHAT_WRITE_FORBIDDENYou can't write in this chat.
400FILE_PARTS_INVALIDThe number of file parts is invalid.
400FILE_PART_LENGTH_INVALIDThe length of a file part is invalid.
400IMAGE_PROCESS_FAILEDFailure while processing image.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400MEDIA_INVALIDMedia invalid.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
400PHOTO_EXT_INVALIDThe extension of the photo is invalid.
400PHOTO_INVALID_DIMENSIONSThe photo dimensions are invalid.
400PHOTO_SAVE_FILE_INVALIDInternal issues, try again later.
400USER_BANNED_IN_CHANNELYou're banned from sending messages in supergroups/channels.
400VOICE_MESSAGES_FORBIDDENThis user's privacy settings forbid you from sending voice messages.
400WEBPAGE_CURL_FAILEDFailure while fetching the webpage with cURL.

References