Browse Source

Fixed 3gp and amr files

Closes #509
master
Igor Zhukov 10 years ago
parent
commit
46dfee6ca5
  1. 19
      app/js/services.js

19
app/js/services.js

@ -1260,27 +1260,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(), randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(),
historyStorage = historiesStorage[peerID], historyStorage = historiesStorage[peerID],
inputPeer = AppPeersManager.getInputPeerByID(peerID), inputPeer = AppPeersManager.getInputPeerByID(peerID),
attachType, fileName; attachType, apiFileName, realFileName;
if (!options.isMedia) { if (!options.isMedia) {
attachType = 'document'; attachType = 'document';
fileName = 'document.' + file.type.split('/')[1]; apiFileName = 'document.' + file.type.split('/')[1];
} else if (['image/jpeg', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) { } else if (['image/jpeg', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) {
attachType = 'photo'; attachType = 'photo';
fileName = 'photo.' + file.type.split('/')[1]; apiFileName = 'photo.' + file.type.split('/')[1];
} else if (file.type.substr(0, 6) == 'video/') { } else if (file.type.substr(0, 6) == 'video/') {
attachType = 'video'; attachType = 'video';
fileName = 'video.mp4'; apiFileName = 'video.mp4';
} else if (file.type.substr(0, 6) == 'audio/') { } else if (file.type.substr(0, 6) == 'audio/') {
attachType = 'audio'; attachType = 'audio';
fileName = 'audio.' + (file.type.split('/')[1] == 'ogg' ? 'ogg' : 'mp3'); apiFileName = 'audio.' + (file.type.split('/')[1] == 'ogg' ? 'ogg' : 'mp3');
} else { } else {
attachType = 'document'; attachType = 'document';
fileName = 'document.' + file.type.split('/')[1]; apiFileName = 'document.' + file.type.split('/')[1];
}
if (!file.name) {
file.name = fileName;
} }
if (historyStorage === undefined) { if (historyStorage === undefined) {
@ -1291,7 +1287,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var media = { var media = {
_: 'messageMediaPending', _: 'messageMediaPending',
type: attachType, type: attachType,
file_name: file.name, file_name: file.name || apiFileName,
size: file.size, size: file.size,
progress: {percent: 1, total: file.size} progress: {percent: 1, total: file.size}
}; };
@ -1333,6 +1329,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
uploadPromise = MtpApiFileManager.uploadFile(file); uploadPromise = MtpApiFileManager.uploadFile(file);
uploadPromise.then(function (inputFile) { uploadPromise.then(function (inputFile) {
inputFile.name = apiFileName;
uploaded = true; uploaded = true;
var inputMedia; var inputMedia;
switch (attachType) { switch (attachType) {

Loading…
Cancel
Save