Skip to content

Post activity with attachment should upload metadata #235

@compulim

Description

@compulim

Background

We recently updated our /upload endpoint to support metadata (e.g. thumbnailUrl) for attachments. The service work is carried out by @NickEricson and did not introduce backward compatibility issues.

This work is required for microsoft/BotFramework-WebChat#2422.

Changes

Instead of removing activity.attachments, we leave the attachments array but only removing activity.attachments[].contentUrl. This will send contentType and thumbnailUrl to the service.

The service will match metadata by looking at:

  • activity.attachments[].name
  • filename of multipart, where the multipart has name equals to file

Quicklook

Today

-------boundary
Content-Disposition: form-data; name="activity"; filename="blob"
Content-Type: application/vnd.microsoft.activity

{
  "from": {
    "id": "dl_1234567"
  },
  "type": "message",
  ...
}
-------boundary
Content-Disposition: form-data; name="file"; filename="abc.png"
Content-Type: image/png

...
-------boundary

Tomorrow

  -------boundary
  Content-Disposition: form-data; name="activity"; filename="blob"
  Content-Type: application/vnd.microsoft.activity

  {
+   "attachments": [{
+     "contentType": "image/png",
+     "name": "abc.png",
+     "thumbnailUrl": "data:image/jpeg;base64,..."
+   }],
    "from": {
      "id": "dl_1234567"
    },
    "type": "message",
    ...
  }
  -------boundary
  Content-Disposition: form-data; name="file"; filename="abc.png"
  Content-Type: image/png

  ...
  -------boundary

Note: the filename field on multipart is used for matching the corresponding item in the attachments array.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions