Hello @tcrusson @brainicorn ,
Could you a post a snippet detailing how to correctly upload a media file? I have checked the documentation but I can not find anything helpful or an example stating the correct way to do so.
Any help is much appreciated.
Hi,
did you check this guide?
Reading Time: 2 minutes Updated February 5, 2019! We previously stated that on February 15th we would start archiving app listings. Instead we will be…
Est. reading time: 2 minutes
Cheers,
Tanguy
@tcrusson , I did so but I am not sure if I am sending it correctly.
const imgBuffer = Buffer.from(response, 'base64');
const header = {
Accept: 'application/json',
'Content-Type': 'application/octet-stream',
};
const params = {
name: 'img.jpg',
};
return this._doPost(
`${BASE_STRIDE_URL}/site/${this.config.cloud_id}/conversation/${this.config.conversation_id}/media`,
header,
imgBuffer,
params
);
How should the image be sent?
Is there another config missing?
Hi @omar.safwany , we’re cooking up sample code and will share it here.
@omar.safwany one more question: what’s the response you’re getting for this endpoint at the moment?
@tcrusson I am getting a normal response which is data object containing the id of the image. However when I open the chat window, I find a thumbnail which is completely white. Nothing to display at all. Also if I try downloading it, I get an error stating the file is corrupted.
How can the file be uploaded? As link, buffer, base64 string or what?
@tcrusson Any updates?
There is nothing here
curl --request POST \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/octet-stream' \
--url 'https://api.atlassian.com/site/{cloudId}/conversation/{conversationId}/media'
stating how the file is sent. I have tried using the following but nothing works.
-F 'data=@path/to/file'
It appears as a broken image when I try to fetch it using the get file endpoint.
@omar.safwany you are meant to send the content as valid application/octet-stream
You can check the Stride reference app to see how you can do it:
https://bitbucket.org/atlassian/stride-apps-reference
This makes use of the Stride node client which you might want to consider using:
Its code is here: Bitbucket