[Suggestion] Rocket Chat files format
Below I have a msg sent into the demo with a image file
{
"_id":"6za25dT2cerChWeTn",
"rid":"FnMWBpumDYqi2LaXzKdgnfaCiHf2yxPiaX",
"msg":"",
"file":{
"_id":"YvdQMNiAYtjWmuYbw"
},
"groupable":false,
"attachments":[
{
"title":"File Uploaded: Screen Shot 2015-12-27 at 12.55.25 PM.png",
"title_link":"/ufs/rocketchat_uploads/YvdQMNiAYtjWmuYbw/Screen Shot 2015-12-27 at 12.55.25 PM.png",
"image_url":"/ufs/rocketchat_uploads/YvdQMNiAYtjWmuYbw/Screen Shot 2015-12-27 at 12.55.25 PM.png",
"image_type":"image/png",
"image_size":42365
}
],
....
and here we have an audio file
{
"_id":"PM8spDaB5mxqrJBis",
"rid":"KdgnfaCiHf2yxPiaXaFZWmPRqvpbZprmjj",
"groupable":false,
"msg":"",
"attachments":[
{
"audio_type":"audio/wav",
"audio_size":136236,
"title":"*File Uploaded*: audiorecord.wavnhttps://demo.rocket.chat/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
"audio_url":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
"title_link":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav"
}
],
"file":{
"_id":"17b0a6ce56a94b9e8"
}
...
-
I don't understand why "file" is not a list or why "attachments" is a list. As far as I understand, each file has its own "file" and an entry in the "atttachments" list. I can see that having the "attachments" field as a list open doors to a multi-file upload option in a single message, but so file should be a list too, right? If someone could clarify that to me, I would be very glad.
-
Why the need to distinct audio and image files? I know that those files have a special way to me shown or played, I guess the media type should be enough to know how to handle the file. It would be a bit troublesome to deal with all possible file formats in the client if more file formats are included. So I would like to change it to a more general format without the prefixes.
"attachments":[
{
"type":"audio/wav",
"size":136236,
"title":"*File Uploaded*: audiorecord.wavnhttps://demo.rocket.chat/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
"url":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
"title_link":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav"
}
],
Looks like a good idea to me
:+1: Saves tons of headache for iOS and many more external integrators to come.
maybe for clarity
type: "audio" mime_type: "audio/wav"
That way if need be things can be handled differently. Simplifies and covers our bases.
@BugsBunnyBR
-
One message can have only one file upload, attachments are not related with file upload, they are only the way to show the file preview, so attachments can have multiple items.
-
Was developed that way to be compatible with the slack format, you can have the image and audio in the same attachment.
I knew that was a reason for this... :(
Thanks to all replies here!
-
Ok, multiple file uploads per message is not possible. Not a problem, one client could just send multiple messages .:-)
-
Ok, slack integration... 2a) How is it possible to have image and audio in the same attachment (which is related to the preview of just one file)? Could you provide an example? I am curious. :-D
2b) The slack format does not seems to help the Rocket Chat clients. Would it be too much trouble to have an integration layer separated from the RC protocol ? I have other API concerns that I would like to share, but it would be another topic and I will do so only if the slack integration is not a main issue.
Seems like we should first and for most design our attachment system well. In my opinion if we design everything to be like slack.... We are doing it very wrong.... Just because they do it doesn't make it right
I am going to agree here with @geekgonecrazy and @BugsBunnyBR. Yes having Slack compatibility is very good, and required, I feel we need to have something more efficient for ourselves than Slack's.
This happens all the time.
A) Internal inter-modules APIs can be designed and tuned for performance and efficiency - at the expense of all other factors.
B) Automated integration APIs should be designed for 100% compatibility with mating systems.
C) External human programmer-facing APIs - if we qualify message formats to be such - should be designed for ease of understanding and simplicity of 'calling code' development.
One solution is to have transformers between (A) <-> (C) or (A) <-> (B)
Personally, I think message formats belong to (A) and that iOS and Android native callers should contort themselves to gain performance/efficiency adapting to (A) without a transforming layer.
IMHO - Slack compatibility should be (B) and an (A)<->(B) transformer makes sense.
@kormic with the iOS side of things might want to take a look at this as well.
@BugsBunnyBR Attachments are not related with file uploads, you can use it to show a file preview or anything else. I'm not saying that we can't change or improve this. Any integration can you the attachments to show things, can be an image and an audio together.
The slack api do not implement the audio and video tags, I added that, we can change that but we should be compatible with slack.
I am on mobile these days...definitely will take a look into this! :)
So... Is there any conclusion or change that will happen from this issue?
It seems like at the very least the properties on attachment should be changed to be generic like you suggested. So that you aren't having to look for a bunch of different attributes to determine what the attachment is.
Hey everybody, sorry for the delay. While I m dealing with other issues right now and I can't have the whole picture, this sounds a good idea to me too. It will be easier to handle the file...