Skip to content

Commit bbceca3

Browse files
committed
Create Blob from Multipart
1 parent 67f743e commit bbceca3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Multipart.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ export class Multipart implements Part {
439439
return Multipart.combineArrays(result);
440440
}
441441

442+
/**
443+
* Create Blob from this multipart.
444+
*
445+
* @throws {@link !RangeError} If the multipart boundary is invalid. A valid boundary is 1 to 70 characters long,
446+
* does not end with space, and may only contain: A-Z a-z 0-9 '()+_,-./:=? and space.
447+
*/
448+
public blob(): Blob {
449+
return new Blob([this.bytes()], {type: this.headers.get("content-type") ?? undefined});
450+
}
451+
442452
private static boundaryShouldBeQuoted(boundary: Uint8Array): boolean {
443453
for (const byte of boundary) {
444454
if (

0 commit comments

Comments
 (0)