Answer the question
In order to leave comments, you need to log in
Python vk api how to send photo without uploading to disk?
How to send a photo without downloading it to disk (so as not to use it and not slow down an already slow process)?
I tried to send the received photo from requests directly to VK, but some error took off
Please help
Answer the question
In order to leave comments, you need to log in
Take the content of the photo into a variable, which is loaded with a post request. An example of a post to a group with an attached photo:
upload_url = vk_api.photos.getWallUploadServer(group_id=group_id)['upload_url']
r = requests.get(image_url)
image_data = r.content
r = requests.post(upload_url, files={'photo': (image_name, image_data) }).json()
d = {}
d['server'] = r['server']
d['photo'] = r['photo']
d['hash'] = r['hash']
d['group_id'] = group_id
photo_id = vk_api.photos.saveWallPhoto(**d)[0]['id']
vk_message = 'Сообщение'
vk_params = { 'message': vk_message, 'from_group': 1, 'owner_id': -group_id }
vk_params['attachments'] = '%s,%s' % (photo_id, image_url)
post_id = vk_api.wall.post(**vk_params)['post_id']
Hello, please tell us how you solved the problem vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: photos_list is
invalid selenium, then I crop it to the desired size using Pillow(PIL) and try to send a byte representation of this screen, but in the Post-request that I send to VK I get the hash and the server, but the sheet with the photo is empty
I thought it might not be in that form I'm sending a VK request with a byte image. I decided to try to send a photo from the Internet using requests .content and I get the same error, although I did everything exactly as shurshur wrote . I honestly can't figure out what the problem is, why the photo is empty...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question