File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ export class Component implements Part {
5454 return new Component ( file . type . length > 0 ? { "Content-Type" : file . type } : { } , await file . arrayBuffer ( ) ) ;
5555 }
5656
57+ /**
58+ * Create a Component from a {@link !Blob}. If blob media type is available,
59+ * it will be set in the `Content-Type` header. The blob's contents will be used as the part's body.
60+ *
61+ * This method might be slow if a large file is provided as the blob contents need to be read.
62+ *
63+ * @param blob Blob to create the component from
64+ */
65+ public static async blob ( blob : Blob ) {
66+ return new Component ( blob . type . length > 0 ? { "Content-Type" : blob . type } : { } , await blob . arrayBuffer ( ) ) ;
67+ }
68+
5769 public bytes ( ) : Uint8Array {
5870 const result : ArrayLike < number > [ ] = [ ] ;
5971 for ( const [ key , value ] of this . headers . entries ( ) )
You can’t perform that action at this time.
0 commit comments