Can send files to conversations

This commit is contained in:
2021-03-06 10:35:54 +01:00
parent c9ddb6f172
commit e89906a640
5 changed files with 151 additions and 79 deletions

View File

@ -10,7 +10,7 @@ const APIClient = {
*
* @returns {Promise}
*/
exec: function(apiURI, args, withLogin){
exec: function(apiURI, args, withLogin) {
if(!args)
args = {};
@ -29,6 +29,24 @@ const APIClient = {
});
},
/**
* @returns {Promise}
*/
execFormData: function(uri, data, withLogin) {
if (!data)
data = new FormData();
return new Promise((res, rej) => {
this.makeFormDatarequest(uri, data, withLogin, (result) => {
if (result.error)
reject(result.error);
else
res(result);
})
});
},
/**
* Make an API request
*

View File

@ -833,4 +833,13 @@ function rpad(str, len, fill) {
while(str.length < len)
str = fill + str
return str
}
/**
* Format file size to human readable format
*
* @param {number} size The size to format
*/
function fileSizeToHuman(size) {
return Math.round(ServerConfig.conf.conversation_files_max_size/(1000*1000)*100)/100 + "MB";
}