M
M
Maxim Yumikov2020-06-26 23:57:21
Python
Maxim Yumikov, 2020-06-26 23:57:21

How to send document vk api python?

Hello, I'm having a problem with uploading a document to private messages. I wanted to upload a database (sq3lite) to private messages, as I am doing an admin panel (there is a check for the administrator, if that helps). Maybe I messed something up or something else is interfering. Waiting for a reply from:

def baza(db):
    a = vk.method("docs.getUploadServer")
    b = requests.post(a['upload_url'], files={'doc': open('user.sqlite', 'rb')}).json()
    c = vk.method('docs.getMessagesUploadServer', {'doc': b['doc'], 'server': b['server'], 'hash': b['hash']})[0]
    d  = "doc{}_{}".format(c["owner_id"], c["id"])
    vk.method("messages.send", {"peer_id": id, "message": "Вот держи базу данных, создатель.", "attachment": d, "random_id": 0})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-27
@SoreMix

vk_api has its own classes and methods for uploading content
https://vk-api.readthedocs.io/en/latest/upload.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question