ContentFileDetails Class

  • java.lang.Object
    • com.azure.search.documents.models.ContentFileDetails

public final class ContentFileDetails

A file in an HTTP request, response, or multipart payload. A file in an HTTP request, response, or multipart payload. Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the operation is treated as a file upload or download. When using file bodies, the fields of the file model are defined to come from particular locations by default: - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or changed). - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload (MAY be overridden or changed). A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON payload, it will have a structure like: ``` { "contentType": <string?>, "filename": <string?>, "contents": <string, base64> } ``` The `contentType` _within_ the file defines what media types the data inside the file can be, but if the specification defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is serialized_. See the examples below for more information. NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart payloads. If you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` location is overridden, as shown in the examples below.

Constructor Summary

Constructor Description
ContentFileDetails(BinaryData content)

Creates an instance of ContentFileDetails class.

Method Summary

Modifier and Type Method and Description
BinaryData getContent()

Get the content property: The content of the file.

String getContentType()

Get the contentType property: The content-type of the file.

String getFilename()

Get the filename property: The filename of the file.

ContentFileDetails setContentType(String contentType)

Set the contentType property: The content-type of the file.

ContentFileDetails setFilename(String filename)

Set the filename property: The filename of the file.

Methods inherited from java.lang.Object

Constructor Details

ContentFileDetails

public ContentFileDetails(BinaryData content)

Creates an instance of ContentFileDetails class.

Parameters:

content - the content value to set.

Method Details

getContent

public BinaryData getContent()

Get the content property: The content of the file.

Returns:

the content value.

getContentType

public String getContentType()

Get the contentType property: The content-type of the file.

Returns:

the contentType value.

getFilename

public String getFilename()

Get the filename property: The filename of the file.

Returns:

the filename value.

setContentType

public ContentFileDetails setContentType(String contentType)

Set the contentType property: The content-type of the file.

Parameters:

contentType - the contentType value to set.

Returns:

the ContentFileDetails object itself.

setFilename

public ContentFileDetails setFilename(String filename)

Set the filename property: The filename of the file.

Parameters:

filename - the filename value to set.

Returns:

the ContentFileDetails object itself.

Applies to