You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider substituting optional BlobPart or sequence<BlobPart> for optional sequence<BlobPart> blobParts at constructor #150
In theory, the type of the argument could have been (BlobPart or sequence) and due to the algorithm for coercing a union type, a lone TypedArray would then end up recognized as a BlobPart rather than a sequence, I believe. That is probably what you were hoping for / would have found more intuitive.
rather than RangeError (Chromium RangeError: byte length of Float32Array should be a multiple of 4; Nightly RangeError: "attempting to construct out-of-bounds TypedArray on ArrayBuffer") due to
file.text().then(console.log).catch(console.error); // new Blob(TypedArray)
Promise {<pending>}
0.000055495012929895890.000064594583818688990.0000586443784413859250.00006201512587722391
instead of
file.text().then(console.log).catch(console.error); // new Blob([TypedArray])
Promise {<pending>}
Q�h8�v�8��u8���8
Will the suggested change break any existing API or be incompatible with implementation that uses File API expecting new Blob(TypedArray) to output a concatenated string of the members of the passed TypedArray?
Actually the use of [] is not particularly problematic from a front-end coding perspective. It is not clearly specified that, or Set is required to avoid conversion to string, at least not immediately clear in plain language at the specification, that could disambiguate from no use of []. Consistency is the purpose of the suggestion: Why does new Blob(void 0) // new Blob(undefined) not output Blob {size: 6, type: ""} or Blob {size: 9, type: ""} if in fact any value not within [] or Set is converted to string?
The change will avoid unexpected results when [] is not used.
If the change is not worth it from a specification perspective a note describing that to avoid string conversion for the case of new Blob(TypedArray), new Blob([TypedArray]) should be used. That is, if including a note clarifying the case is not expensive: it would certainly be useful for readers of specification, and a reference point.
The adjacent, or opposite, case is passing an array of TypedArrays, to Blob() with [] included, e.g., new Blob([[Uint8Array, Uint8Array, ..., Uint8Array]]) where when the data is attempted to be converted back to original values, the result will not be expected. In brief,
Or, are the above examples simply relegated to PEBCAK, without need for note to user re use of [] or not at Blob constructor? If so, kindly close the issue.
However, somehow I cannot completely solve the problem by using your code. It is not possible to create a file from the incoming form data. TypeError: Failed to construct 'File': The provided value cannot be converted to a sequence. – dan_boy May 10 at 7:40
Am not sure what response.data.file is or expected to be in the code.
Activity
guest271314 commentedon Apr 5, 2020
Use case
If
new Blob(undefined)#33 can be handled to outputBlob {size: 0, type: ""}Similarly
new Blob(new Float32Array([0.00005549501292989589, 0.00006459458381868899, 0.000058644378441385925, 0.00006201512587722391]))should be handled to output
rather than
RangeError(ChromiumRangeError: byte length of Float32Array should be a multiple of 4; NightlyRangeError: "attempting to construct out-of-bounds TypedArray on ArrayBuffer") due toinstead of
Will the suggested change break any existing API or be incompatible with implementation that uses File API expecting
new Blob(TypedArray)to output a concatenated string of the members of the passedTypedArray?domenic commentedon Apr 5, 2020
It seems the use case here is allowing you to avoid typing
[and]. I'm not sure that's worth the churn.guest271314 commentedon Apr 5, 2020
Actually the use of
[]is not particularly problematic from a front-end coding perspective. It is not clearly specified that, orSetis required to avoid conversion to string, at least not immediately clear in plain language at the specification, that could disambiguate from no use of[]. Consistency is the purpose of the suggestion: Why doesnew Blob(void 0) // new Blob(undefined)not outputBlob {size: 6, type: ""}orBlob {size: 9, type: ""}if in fact any value not within[]orSetis converted to string?The change will avoid unexpected results when
[]is not used.If the change is not worth it from a specification perspective a note describing that to avoid string conversion for the case of
new Blob(TypedArray),new Blob([TypedArray])should be used. That is, if including a note clarifying the case is not expensive: it would certainly be useful for readers of specification, and a reference point.guest271314 commentedon Apr 5, 2020
The adjacent, or opposite, case is passing an array of
TypedArrays, toBlob()with[]included, e.g.,new Blob([[Uint8Array, Uint8Array, ..., Uint8Array]])where when the data is attempted to be converted back to original values, the result will not be expected. In brief,Now, if we try we will get an error
where if we got back the same results we will get
What happened to the original input data? Simply using
[]directly affected the result when converting back to original data?Evidently, yes. In this case, potentially relatively common, the resulting promise value from
Promise.all(), we do not need to use[]guest271314 commentedon Apr 5, 2020
Or, are the above examples simply relegated to PEBCAK, without need for note to user re use of
[]or not atBlobconstructor? If so, kindly close the issue.guest271314 commentedon May 14, 2020
From the wild https://stackoverflow.com/questions/61620389/how-to-load-previous-state-of-file-field-in-react#comment109152574_61620572 at https://stackoverflow.com/q/61620389
Am not sure what
response.data.fileis or expected to be in the code.