Skip to content

Commit

Permalink
Fixed handling of attachments sent from a bot.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Jun 27, 2019
1 parent b41a4ee commit 8a1d7c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed
- [client/main] Auto update is now opt-in by default and changed UX to reflect this in PR [1575](https://github.com/microsoft/BotFramework-Emulator/pull/1575)
- [client/main] Fixed OAuth card sign-in flow when not using magic code in PR [1660](https://github.com/microsoft/BotFramework-Emulator/pull/1660)
- [client/main] Fixed issue where images uploaded from the bot weren't being handled properly in PR [1661](https://github.com/microsoft/BotFramework-Emulator/pull/1661)

## v4.4.2 - 2019 - 05 - 28
## Fixed
Expand Down
Expand Up @@ -52,7 +52,12 @@ export default function getAttachment(bot: BotEmulator) {
const attachmentBase64 = parms.viewId === 'original' ? attachment.originalBase64 : attachment.thumbnailBase64;

if (attachmentBase64) {
const buffer = Buffer.from(Buffer.from(attachmentBase64.buffer as ArrayBuffer).toString(), 'base64');
// can be an ArrayBuffer if uploaded via the Web Chat paperclip control, or can be
// an already-encoded base64 content string if sent from the bot
const bufferContents = attachmentBase64.buffer
? Buffer.from(attachmentBase64.buffer as ArrayBuffer).toString()
: attachmentBase64.toString();
const buffer = Buffer.from(bufferContents, 'base64');

res.contentType = attachment.type;
res.send(HttpStatus.OK, buffer);
Expand Down

0 comments on commit 8a1d7c5

Please sign in to comment.