Skip to content

Commit 4d97299

Browse files
committed
fix: use Buffer.from
1 parent d820b4c commit 4d97299

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/GraphQL/loaders/filesMutations.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@ import Parse from 'parse/node';
44
import * as defaultGraphQLTypes from './defaultGraphQLTypes';
55
import logger from '../../logger';
66

7-
function toBuffer(ab) {
8-
const buf = Buffer.alloc(ab.byteLength);
9-
const view = new Uint8Array(ab);
10-
for (let i = 0; i < buf.length; ++i) {
11-
buf[i] = view[i];
12-
}
13-
return buf;
14-
}
15-
167
const handleUpload = async (upload, config) => {
17-
const data = toBuffer(await upload.arrayBuffer());
8+
const data = Buffer.from(await upload.arrayBuffer());
189
console.log(data.length);
1910
const fileName = upload.name;
2011
const type = upload.type;

0 commit comments

Comments
 (0)