Skip to content

Commit

Permalink
feat: 为request兼容ArrayBuffer数据
Browse files Browse the repository at this point in the history
  • Loading branch information
chenai02 committed Jun 5, 2024
1 parent 851500f commit 864a456
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Taro from '@tarojs/api'
import { fromByteArray } from 'base64-js'

import { ClassInstanceManager } from './ClassInstanceManager'

Expand All @@ -7,6 +8,10 @@ export class NativeRequest implements Taro.RequestTask<any> {
readonly [Symbol.toStringTag]: string = ''
private objectId: number
constructor (option: any) {
if (option?.data instanceof ArrayBuffer) {
option.bufBase64 = fromByteArray(new Uint8Array(option.data))
option.data = undefined
}
const options = {
...option,
success: (res: any) => {
Expand Down

0 comments on commit 864a456

Please sign in to comment.