@mtproto/core
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "@mtproto/core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Telegram API for browser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,2 +7,3 @@ const debounce = require('lodash.debounce'); | ||
const { | ||
arrayBufferToBase64, | ||
bigStringInt, | ||
@@ -1241,4 +1242,15 @@ bytesToHex, | ||
} | ||
getFileInBase64({ location, offset = 0, limit = 1024 * 1024 }) { | ||
return this.call('upload.getFile', { | ||
flags: 0, | ||
offset, | ||
limit, | ||
location, | ||
}).then(response => { | ||
return arrayBufferToBase64(response.bytes); | ||
}); | ||
} | ||
} | ||
module.exports = API; |
@@ -97,2 +97,12 @@ const { Zlib } = require('zlibjs/bin/gunzip.min.js'); | ||
function arrayBufferToBase64(buffer) { | ||
var binary = ''; | ||
var bytes = new Uint8Array(buffer); | ||
var len = bytes.byteLength; | ||
for (var i = 0; i < len; i++) { | ||
binary += String.fromCharCode(bytes[i]); | ||
} | ||
return window.btoa(binary); | ||
} | ||
function uint6ToBase64(nUint6) { | ||
@@ -744,2 +754,3 @@ return nUint6 < 26 | ||
base64ToBlob, | ||
arrayBufferToBase64, | ||
dataUrlToBlob, | ||
@@ -746,0 +757,0 @@ blobConstruct, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
402617
14040