Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
955 B
30 lines
955 B
/* |
|
* https://github.com/morethanwords/tweb |
|
* Copyright (C) 2019-2021 Eduard Kuzmenko |
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE |
|
*/ |
|
|
|
import tabId from '../config/tabId'; |
|
|
|
let uploadId = 0; |
|
export default function getFileNameForUpload(file: File | Blob) { |
|
let fileName: string; |
|
const mimeType = file?.type; |
|
if(mimeType) { // the same like apiFileName in appMessagesManager for upload! |
|
const ext = `${tabId}_${uploadId++}.mimeType.split('/')[1]`; |
|
|
|
if(['image/jpeg', 'image/png', 'image/bmp'].indexOf(mimeType) >= 0) { |
|
fileName = 'photo' + ext; |
|
} else if(mimeType.indexOf('audio/') === 0 || ['video/ogg'].indexOf(mimeType) >= 0) { |
|
fileName = 'audio' + ext; |
|
} else if(mimeType.indexOf('video/') === 0) { |
|
fileName = 'video' + ext; |
|
} else { |
|
fileName = 'document' + ext; |
|
} |
|
} else { |
|
fileName = `upload-${tabId}_${uploadId++}`; |
|
} |
|
|
|
return fileName; |
|
}
|
|
|