瀏覽代碼

Fix uploads from file path.

Painor 8 月之前
父節點
當前提交
273a6f498c
共有 2 個文件被更改,包括 10 次插入2 次删除
  1. 1 1
      gramjs/Version.ts
  2. 9 1
      gramjs/client/uploads.ts

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "2.24.8";
+export const version = "2.25.0";

+ 9 - 1
gramjs/client/uploads.ts

@@ -155,7 +155,15 @@ export async function uploadFile(
         }
 
         for (let j = i; j < end; j++) {
-            const bytes = await buffer.slice(j * partSize, (j + 1) * partSize);
+            let endPart = (j + 1) * partSize;
+            if (endPart > size) {
+                endPart = size;
+            }
+            if (endPart == j * partSize) {
+                break;
+            }
+
+            const bytes = await buffer.slice(j * partSize, endPart);
 
             // eslint-disable-next-line no-loop-func
             sendingParts.push(