matlab.net.http.io.ImageProvider class
Package:matlab.net.http.io
Superclasses:matlab.net.http.io.ContentProvider
ContentProvider to sendMATLABimage data
Description
使用一个ImageProvider
object to convert and send MATLAB®image data in an HTTPRequestMessage
. This provider converts the data to one of the standard types, as specified by the Content-Type of the request or properties in this object. This provider also converts an image file to a different format.
By default, if you specify an image Content-Type in theRequestMessage
, for example"image/jpeg"
andRequestMessage.Body
is aMessageBody
containing your image data, then MATLAB assumes thatMessageBody.Data
is image data and tries to convert it appropriately. To control how your data is converted, use anImageProvider
inRequestMessage.Body
.
If theRequestMessage
does not contain a Content-Type header field, then this provider adds the appropriate image Content-Type to the header. Otherwise, the header field is not modified and conversion is done as specified in the properties of this object, even if its value is inconsistent with the Content-Type field.
Thematlab.net.http.io.ImageProvider
class is ahandle
class.
Creation
Description
provider = ImageProvider(
obtains the image data from the filefilename
,arg1,...,argN
)filename
and sends it in the format specified inarg1,...,argN
or the Content-Type field, setting theFilenameproperty tofilename
.
While this provider can convert a file in one format to data in another format, it is not designed to send an image file as is. To send a file without changing its type, use aFileProvider
.
Properties
Public Properties
Data
—MATLAB数据转换
MATLAB type
This is the value specified as the Data argument to the constructor, if any, or the data converted from thefilename
argument. Set this value to a string scalar or character vector before sending the message containing this provider.
If a subclass author wants to set this property before MATLAB calls thestart
method, then set the value in thecomplete
method. If you change this property, then the change takes effect with the next call tostart
.
Attributes:
GetAccess |
public
|
SetAccess |
public
|
Arguments
—Arguments toimwrite
function
cell array
Arguments to theimwrite
function, specified as a cell array. This is the value specified to the constructor containing a list of arguments as documented forimwrite
, but omitting the image data and file name arguments.
Subclass authors can set this property before MATLAB callsstart
, for example, incomplete
. If you change these values, then the changes do not take effect until the next call tostart
.
Attributes:
GetAccess |
public
|
SetAccess |
public
|
Dependent |
true
|
Filename
—File containing image data
string
Name of the file containing the image data, specified as a string. This is the value specified as thefilename
argument to the constructor, if any. It is read-only.
The format offilename
is derived from the file name extension, which might be different from thefmt
argument inarg1,...,argN
or the Content-Type in the message. This constructor syntax allows you to send an image file in one format to a server that expects it in a different format. However, some conversions are incompatible. For example, you cannot convert an RGB file like JPEG to a GIF format.
Attributes:
GetAccess |
public
|
SetAccess |
private
|
Header
—Header fields of message or part
matlab.net.http.HeaderField.empty
(default) |matlab.net.http.HeaderField
Header fields of the message or part, specified as a vector of one or morematlab.net.http.HeaderField
objects.
This property is only used by subclass authors. MATLAB sets this property before calling the provider'scomplete
method. For non-multipart messages, MATLAB initializes this property to the contents ofRequest.Header
, minus anymatlab.net.http.field.GenericFields
or empty-valued fields. TheContentProvider
uses this property to add header fields that describe the data to be sent, or to add parameters to header fields already in the message. In a delegate for aMultipartProvider
, MATLAB initializes this property to header fields that the delegating provider intends to insert for the part. Delegates can modify or change these fields.
Upon return from the provider'scomplete
method, if this not a multipart message, then MATLAB reads this property and merges its contents into the header ofRequest
. Fields in thisHeader
withNames
that do not already appear inRequest.Header
are added to the end ofRequest.Header
. If a field in thisHeader
has aName
这是一样的Request.Header
, and both have nonemptyValues
then:
If the one in
Request.Header
is aGenericField
then ignore the one inHeader
.If the one in
Request.Header
is not aGenericField
then replace it with the one inHeader
.
If one or both of these has an emptyValue
then the field is removed fromRequest.Header
and it is not added as part of normal message completion.
If this is a delegate of aMultipartProvider
then the entire contents of thisHeader
is used as the header of the part. Multipart delegates must not assume thatRequest.Header
contains any fields pertaining to their ownHeader
. A provider can determine whether it is a multipart delegate by checking whetherMyDelegator
is aMultipartProvider
though this test is unlikely to be needed.
MATLAB reads this property only on return from calling the provider'scomplete
method. Changes to this array are ignored once MATLAB callsstart
.
Class authors should be aware that their subclasses might have added fields to thisHeader
(in theircomplete
method) before callingcomplete
in their superclass. It is best to preserve such fields and not to add fields with the same names. However, adding a parameter to a field is permissible. For example, a superclass can add a charset parameter to an existing Content-Type field that does not already have one.
Attributes:
GetAccess |
public
|
SetAccess |
public
|
ForceChunked
—Indicate whether to force chunked transfer coding
false
(default) |true
Indicate whether to force chunked transfer coding, specified as boolean. This property is of interest only to subclass authors, and is applicable only to providers that are not multipart delegates. Subclasses setForceChunked
to control whether contents should be sent using chunked transfer coding. Iffalse
(default), MATLAB decides whether to send the contents chunked, based on whether it knows the content length at the time the message is ready to be sent:
If MATLAB knows the content length (which is the case if the message contains a Content-Length field, or if this provider's
expectedContentLength
method returned a number), then MATLAB decides whether to send it chunked or not.If MATLAB does not know the content length (no Content-Length field in the header and
expectedContentLength
returned empty), then MATLAB always sends the message chunked.
IfForceChunked
istrue
then MATLAB sends the message chunked regardless of whether it knows the content length, unless the known length is smaller than the chunk size. If this property istrue
then the message must not contain a Content-Length field, because HTTP does not allow a chunked message to have a Content-Length field. However, you can still return a nonzero value in theexpectedContentLength
method if you want MATLAB to verify that you are returning the expected length of data.
When MATLAB chooses to send the message chunked, the size of each chunk is equal to the length of data returned bygetData
.
MATLAB reads this value after calling thecomplete
method, before callingstart
. It does not set this field.
Attributes:
GetAccess |
public
|
SetAccess |
public
|
Request
—Request message to send
matlab.net.http.RequestMessage
Request message to send, specified as amatlab.net.http.RequestMessage
object.
This property is used only by subclass authors. TheRequestMessage.send
andRequestMessage.complete
methods set this property to theRequestMessage
in whoseBody
this provider has been placed, before calling any other methods in this provider, and before adding any additional header fields or validating the message. The provider can examine this message to see what was contained in the original request.
Delegates see the same value for this property as the delegator.ContentProviders
应该意识到,如果他们的代表,他们呢are not necessarily providing the entire body of the request message, so they should not assume that header fields in this Request are pertinent to the data they are providing. Usually, delegates should ignore header fields in this request relevant to the data, such as Content-Type.
If the provider wishes to add any header fields to this message, or to modify existing ones, it should do so in itscomplete
method by adding those fields to theHeader
property. The caller ofcomplete
(RequestMessage
or a delegating provider) determines what to do with those fields.RequestMessage.send
andRequestMessage.complete
always copy these fields to theHeader
of theRequestMessage
. A delegating provider can copy the fields to its ownHeader
property or insert them into the message (as in the case ofMultipartProvider
). For more information, see theHeaderproperty.
This property is read-only.
Attributes:
GetAccess |
public |
SetAccess |
matlab.net.http.RequestMessage |
Protected Properties
CurrentDelegate
—ContentProvider
to which this provider is delegating
matlab.net.http.io.ContentProvider
|empty
ContentProvider
to which this provider is delegating, specified as amatlab.net.http.io.ContentProvider
object. This property is set in the calling provider (the delegator) by thedelegateTo
method to indicate the current delegated provider. If there is no current delegation, then the value is empty.
Thecomplete
methods set this property to empty.
Attributes:
GetAccess |
protected
|
SetAccess |
protected
|
MyDelegator
—ContentProvider
that delegated to this provider
matlab.net.http.io.ContentProvider.empty
(default) |matlab.net.http.io.ContentProvider
ContentProvider
that delegated to this provider, specified as amatlab.net.http.io.ContentProvider
object.
If aContentProvider
delegates responsibility for sending all or a portion of the message data to another provider, then this property identifies the delegating provider to the delegate. For example, aMultipartProvider
delegates parts of the message to other providers, so it inserts a handle to itself in each delegate. Otherwise,MyDelegator
is empty. ThedelegateTo
method sets this property in the delegate.
Attributes:
GetAccess |
protected
|
SetAccess |
protected
|
Methods
Public Methods
getData |
下一个buffer of data to send in HTTP request message from ContentProvider |
Specialized Operators and Functions
These methods specialize standard MATLAB operators and functions and inherited methods for objects in this class.
string |
|
show |
Display |
Protected Methods
complete |
Complete HTTP header for ImageProvider |
preferredBufferSize |
Preferred buffer size for ContentProvider |
expectedContentLength |
Content length of ContentProvider |
start |
Start data transfer from ImageProvider |
可重新开始的 |
Indicate whether ImageProvider is restartable |
reusable |
Indicate whether ImageProvider is reusable |
delegateTo |
Delegate to another provider |
More About
Class Hierarchy
Version History
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)