Trying to upload image results in 400 error
I'm using the following code to upload an image directly:
var data = fs.readFileSync(__dirname + '/' + radar).toString("base64");
var base64Image = 'data:image/gif;base64,' + data;
var msg = new builder.Message(session).addAttachment({
contentType: "image/gif",
content: base64Image
});
session.send(msg);
Here's the error I get back:
error:
{ code: 'MalformedData',
message: 'The request content length exceeded limit of 256K',
statusCode: 400 } } }
I had no issues uploading directly to Facebook and Slack via their multi-part from data POST API and want to make a platform-agnostic version.
@tomlm @Stevenic Am I doing this right? It seems like, according to the REST API documentation, this uploads to blob storage. I don't really need that, just a way to send a GIF directly to a channel.
Is there a way to do this or do I have to do it manually for each channel?
@tomlm can you comment or close?
Hi @MironV, the error in this case relates to the total message size -- we cap the entire Activity payload at 256K. One option is to simply host the image and reference it by URL. We'll look at increasing the limit but there may always end up being a cap, and in those cases, sending the image by URL will be the best solution.
Closing issue as the message size cap is not going away (even if we change it). Please at-mention or open a new issue if you'd like to discuss further. Thanks!