Constructs an ElementWithBody.
The Element, with the usual "id", "type", "length", and "attributes" properties,
and where the "body" property can be a ReadableStream
The identifier of the element within the digital object. This is used to reference the element when retrieving it.
OptionaltypeThe MIME type of the element's content. For example, "application/pdf" or "image/jpeg".
OptionallengthThe length of the element's content in bytes.
OptionalattributesAdditional metadata about the element. This can include information like filename.
The binary content of the element as a readable stream. This is typically present when retrieving an element or when creating/updating an element with streaming content. When making a request, ElementWithBody can be used to provide the element bytes using other JavaScript types.
In situations where we can't just use ReadableStream -- namely, browsers which don't support ReadableStream requests in fetch -- we may want to know whether we had a ReadableStream or a Blob (in particular, a File) in order to construct a request with the minimum of reading things into memory.
This helper class can be used to create a new element with a body to attach to a Digital Object.
Example