VK icon

VK

Работа с API ВКонтакте (личная страница)

📝 Постинг контента → Загрузить фото

AI-generated

Summary

Upload a photo to a VK wall or to a private message and receive the corresponding attachment string for use in posts or messages.

Inputs

  • uploadTarget (required) — Choose whether to upload the photo to a wall post ('wall') or a private message ('message').
  • groupId — Required when uploading to a wall: use 0 for own wall or a positive number for a community/group wall ID.
  • peerId — Required when uploading to a message: the ID of the message recipient.
  • fileSource (required) — Select source of the photo file to upload: 'url' to download from a link, or 'binary' to use binary data from a previous node.
  • fileUrl (required) — When 'fileSource' is 'url', specify the full URL to the photo to download and upload.
  • binaryProperty (required) — When 'fileSource' is 'binary', specify the name of the binary data property from the previous node containing the photo file.
  • caption — Optional caption text to add to the uploaded photo.

Output shape

a list of JSON objects each representing an uploaded photo with VK attachment string (_attachment property) for use in wall posts or messages.

Each item in the output corresponds to one photo uploaded; attachment string follows the format 'photo{owner_id}{id}_{access_key?}'. Errors are thrown on upload failure.

Examples

Example 1: Upload a photo by URL to a community wall with a caption

Set 'uploadTarget' to 'wall', provide 'groupId' of the community, specify 'fileSource' as 'url' with the 'fileUrl', and enter a 'caption'.

Example 2: Upload a photo from binary data into a private message

Set 'uploadTarget' to 'message', specify the 'peerId' of the recipient, set 'fileSource' to 'binary' and the 'binaryProperty' holding the photo file.

Links

Discussion