Updates: Check the release notes for new features and product updates.

Method: media.upload

Uploads a file blob for use in media or rich card messages.

The agent provides the blob of the file. The thumbnail of the file will be generated by Google automatically. The RBM platform caches the file for 60 days and returns a unique name that you can use to identify the file when sending agent messages.

HTTP request

  • Upload URI, for media upload requests:

    POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files:upload

  • Metadata URI, for metadata-only requests:

    POST https://rcsbusinessmessaging.googleapis.com/v1/files:upload

The URL uses gRPC Transcoding syntax.

Request body

The request body contains data with the following structure:

JSON representation
{
  "blob": {
    object (Media)
  }
}
Fields
blob

object (Media)

Blob file reference

Response body

If successful, the response body contains an instance of File.

Authorization Scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/rcsbusinessmessaging

For more information, see the OAuth 2.0 Overview.

Media

A reference to data stored on the filesystem, on GFS or in blobstore.

JSON representation
{
  "contentType": string,
  "timestamp": string,
  "token": string,
  "length": string,
  "filename": string,
  "referenceType": enum (ReferenceType),
  "path": string,
  "blobRef": string,
  "inline": string,
  "mediaId": string,
  "hash": string,
  "algorithm": string,
  "compositeMedia": [
    {
      object (CompositeMedia)
    }
  ],
  "bigstoreObjectRef": string,
  "objectId": {
    object (ObjectId)
  },
  "blobstore2Info": {
    object (Blobstore2Info)
  },
  "diffVersionResponse": {
    object (DiffVersionResponse)
  },
  "diffChecksumsResponse": {
    object (DiffChecksumsResponse)
  },
  "diffDownloadResponse": {
    object (DiffDownloadResponse)
  },
  "diffUploadRequest": {
    object (DiffUploadRequest)
  },
  "diffUploadResponse": {
    object (DiffUploadResponse)
  },
  "contentTypeInfo": {
    object (ContentTypeInfo)
  },
  "downloadParameters": {
    object (DownloadParameters)
  },
  "crc32cHash": number,
  "md5Hash": string,
  "sha1Hash": string,
  "sha256Hash": string,
  "isPotentialRetry": boolean,
  "cosmoBinaryReference": string,
  "hashVerified": boolean
}
Fields
contentType

string

MIME type of the data

timestamp

string

Time at which the media data was last updated, in milliseconds since UNIX epoch

token

string

A unique fingerprint/version id for the media data

length

string (int64 format)

Size of the data, in bytes

filename

string

Original file name

referenceType

enum (ReferenceType)

Describes what the field reference contains.

path

string

Path to the data, set if referenceType is PATH

blobRef
(deprecated)

string (bytes format)

Blobstore v1 reference, set if referenceType is BLOBSTORE_REF This should be the byte representation of a blobstore.BlobRef. Since Blobstore is deprecating v1, use blobstore2Info instead. For now, any v2 blob will also be represented in this field as v1 BlobRef.

A base64-encoded string.

inline

string (bytes format)

Media data, set if referenceType is INLINE

A base64-encoded string.

mediaId

string (bytes format)

Media id to forward to the operation GetMedia. Can be set if referenceType is GET_MEDIA.

A base64-encoded string.

hash
(deprecated)

string

Deprecated, use one of explicit hash type fields instead. These two hash related fields will only be populated on Scotty based media uploads and will contain the content of the hash group in the NotificationRequest: https://cs/#google3/uploader/service/proto/upload_listener.proto&q=class:Hash Hex encoded hash value of the uploaded media.

algorithm
(deprecated)

string

Deprecated, use one of explicit hash type fields instead. Algorithm used for calculating the hash. As of 2011/01/21, "MD5" is the only possible value for this field. New values may be added at any time.

compositeMedia[]

object (CompositeMedia)

A composite media composed of one or more media objects, set if referenceType is COMPOSITE_MEDIA. The media length field must be set to the sum of the lengths of all composite media objects.

Note: All composite media must have length specified.

bigstoreObjectRef
(deprecated)

string (bytes format)

Use objectId instead.

A base64-encoded string.

objectId

object (ObjectId)

Reference to a TI Blob, set if referenceType is BIGSTORE_REF.

blobstore2Info

object (Blobstore2Info)

Blobstore v2 info, set if referenceType is BLOBSTORE_REF and it refers to a v2 blob.

diffVersionResponse

object (DiffVersionResponse)

Set if referenceType is DIFF_VERSION_RESPONSE.

diffChecksumsResponse

object (DiffChecksumsResponse)

Set if referenceType is DIFF_CHECKSUMS_RESPONSE.

diffDownloadResponse

object (DiffDownloadResponse)

Set if referenceType is DIFF_DOWNLOAD_RESPONSE.

diffUploadRequest

object (DiffUploadRequest)

Set if referenceType is DIFF_UPLOAD_REQUEST.

diffUploadResponse

object (DiffUploadResponse)

Set if referenceType is DIFF_UPLOAD_RESPONSE.

contentTypeInfo

object (ContentTypeInfo)

Extended content type information provided for Scotty uploads.

downloadParameters

object (DownloadParameters)

Parameters for a media download.

crc32cHash

number

For Scotty Uploads: Scotty-provided hashes for uploads

For Scotty Downloads: (WARNING: DO NOT USE WITHOUT PERMISSION FROM THE SCOTTY TEAM.) A Hash provided by the agent to be used to verify the data being downloaded. Currently only supported for inline payloads. Further, only crc32cHash is currently supported.

md5Hash

string (bytes format)

Scotty-provided MD5 hash for an upload.

A base64-encoded string.

sha1Hash

string (bytes format)

Scotty-provided SHA1 hash for an upload.

A base64-encoded string.

sha256Hash

string (bytes format)

Scotty-provided SHA256 hash for an upload.

A base64-encoded string.

isPotentialRetry

boolean

|isPotentialRetry| is set false only when Scotty is certain that it has not sent the request before. When a client resumes an upload, this field must be set true in agent calls, because Scotty cannot be certain that it has never sent the request before due to potential failure in the session state persistence.

cosmoBinaryReference

string (bytes format)

A binary data reference for a media download. Serves as a technology-agnostic binary reference in some Google infrastructure. This value is a serialized storage_cosmo.BinaryReference proto. Storing it as bytes is a hack to get around the fact that the cosmo proto (as well as others it includes) doesn't support JavaScript. This prevents us from including the actual type of this field.

A base64-encoded string.

hashVerified

boolean

For Scotty uploads only. If a user sends a hash code and the backend has requested that Scotty verify the upload against the client hash, Scotty will perform the check on behalf of the backend and will reject it if the hashes don't match. This is set to true if Scotty performed this verification.

ReferenceType

Describes what the field reference contains. More types can be added over time. Implementations should handle unknown reference types as gracefully as possible.

Enums
PATH Reference contains a GFS path or a local path.
BLOB_REF Reference points to a blobstore object. This could be either a v1 blobRef or a v2 blobstore2Info. Clients should check blobstore2Info first, since v1 is being deprecated.
INLINE Data is included into this proto buffer
GET_MEDIA Data should be accessed from the current service using the operation GetMedia.
COMPOSITE_MEDIA The content for this media object is stored across multiple partial media objects under the compositeMedia field.
BIGSTORE_REF Reference points to a bigstore object
DIFF_VERSION_RESPONSE Indicates the data is stored in diffVersionResponse.
DIFF_CHECKSUMS_RESPONSE Indicates the data is stored in diffChecksumsResponse.
DIFF_DOWNLOAD_RESPONSE Indicates the data is stored in diffDownloadResponse.
DIFF_UPLOAD_REQUEST Indicates the data is stored in diffUploadRequest.
DIFF_UPLOAD_RESPONSE Indicates the data is stored in diffUploadResponse.
COSMO_BINARY_REFERENCE Indicates the data is stored in cosmoBinaryReference.
ARBITRARY_BYTES

Informs Scotty to generate a response payload with the size specified in the length field. The contents of the payload are generated by Scotty and are undefined. This is useful for testing download speeds between the user and Scotty without involving a real payload source.

Note: range is not supported when using arbitrary_bytes.

CompositeMedia

A sequence of media data references representing composite data. Introduced to support Bigstore composite objects. For details, visit http://go/bigstore-composites.

JSON representation
{
  "length": string,
  "referenceType": enum (ReferenceType),
  "path": string,
  "blobRef": string,
  "inline": string,
  "objectId": {
    object (ObjectId)
  },
  "blobstore2Info": {
    object (Blobstore2Info)
  },
  "cosmoBinaryReference": string,
  "crc32cHash": number,
  "md5Hash": string,
  "sha1Hash": string
}
Fields
length

string (int64 format)

Size of the data, in bytes

referenceType

enum (ReferenceType)

Describes what the field reference contains.

path

string

Path to the data, set if referenceType is PATH

blobRef
(deprecated)

string (bytes format)

Blobstore v1 reference, set if referenceType is BLOBSTORE_REF This should be the byte representation of a blobstore.BlobRef. Since Blobstore is deprecating v1, use blobstore2Info instead. For now, any v2 blob will also be represented in this field as v1 BlobRef.

A base64-encoded string.

inline

string (bytes format)

Media data, set if referenceType is INLINE

A base64-encoded string.

objectId

object (ObjectId)

Reference to a TI Blob, set if referenceType is BIGSTORE_REF.

blobstore2Info

object (Blobstore2Info)

Blobstore v2 info, set if referenceType is BLOBSTORE_REF and it refers to a v2 blob.

cosmoBinaryReference

string (bytes format)

A binary data reference for a media download. Serves as a technology-agnostic binary reference in some Google infrastructure. This value is a serialized storage_cosmo.BinaryReference proto. Storing it as bytes is a hack to get around the fact that the cosmo proto (as well as others it includes) doesn't support JavaScript. This prevents us from including the actual type of this field.

A base64-encoded string.

crc32cHash

number

crc32.c hash for the payload.

md5Hash

string (bytes format)

MD5 hash for the payload.

A base64-encoded string.

sha1Hash

string (bytes format)

SHA-1 hash for the payload.

A base64-encoded string.

ReferenceType

Describes what the field reference contains. More types can be added over time. Implementations should handle unknown reference types as gracefully as possible.

Enums
PATH Reference contains a GFS path or a local path.
BLOB_REF Reference points to a blobstore object. This could be either a v1 blobRef or a v2 blobstore2Info. Clients should check blobstore2Info first, since v1 is being deprecated.
INLINE Data is included into this proto buffer
BIGSTORE_REF Reference points to a bigstore object
COSMO_BINARY_REFERENCE Indicates the data is stored in cosmoBinaryReference.

ObjectId

This is a copy of the tech.blob.ObjectId proto, which could not be used directly here due to transitive closure issues with JavaScript support; see http://b/8801763.

JSON representation
{
  "bucketName": string,
  "objectName": string,
  "generation": string
}
Fields
bucketName

string

The name of the bucket to which this object belongs.

objectName

string

The name of the object.

generation

string (int64 format)

Generation of the object. Generations are monotonically increasing across writes, allowing them to be be compared to determine which generation is newer. If this is omitted in a request, then you are requesting the live object. See https://go/bigstore-versions

Blobstore2Info

Information to read/write to blobstore2.

JSON representation
{
  "blobId": string,
  "blobGeneration": string,
  "readToken": string,
  "uploadMetadataContainer": string,
  "downloadReadHandle": string
}
Fields
blobId

string

The blob id, e.g., /blobstore/prod/playground/scotty

blobGeneration

string (int64 format)

The blob generation id.

readToken

string

The blob read token. Needed to read blobs that have not been replicated. Might not be available until the final call.

uploadMetadataContainer

string (bytes format)

Metadata passed from Blobstore -> Scotty for a new GCS upload. This is a signed, serialized blobstore2.BlobMetadataContainer proto which must never be consumed outside of Bigstore, and is not applicable to non-GCS media uploads.

A base64-encoded string.

downloadReadHandle

string (bytes format)

Read handle passed from Bigstore -> Scotty for a GCS download. This is a signed, serialized blobstore2.ReadHandle proto which must never be set outside of Bigstore, and is not applicable to non-GCS media downloads.

A base64-encoded string.

DiffVersionResponse

Backend response for a Diff get version response. For details on the Scotty Diff protocol, visit http://go/scotty-diff-protocol.

JSON representation
{
  "objectVersion": string,
  "objectSizeBytes": string
}
Fields
objectVersion

string

The version of the object stored at the server.

objectSizeBytes

string (int64 format)

The total size of the server object.

DiffChecksumsResponse

Backend response for a Diff get checksums response. For details on the Scotty Diff protocol, visit http://go/scotty-diff-protocol.

JSON representation
{
  "objectVersion": string,
  "objectSizeBytes": string,
  "chunkSizeBytes": string,
  "checksumsLocation": {
    object (CompositeMedia)
  },
  "objectLocation": {
    object (CompositeMedia)
  }
}
Fields
objectVersion

string

The object version of the object the checksums are being returned for.

objectSizeBytes

string (int64 format)

The total size of the server object.

chunkSizeBytes

string (int64 format)

The chunk size of checksums. Must be a multiple of 256KB.

checksumsLocation

object (CompositeMedia)

Exactly one of these fields must be populated.

If checksumsLocation is filled, the server will return the corresponding contents to the user. If objectLocation is filled, the server will calculate the checksums based on the content there and return that to the user. For details on the format of the checksums, see http://go/scotty-diff-protocol.

objectLocation

object (CompositeMedia)

If set, calculate the checksums based on the contents and return them to the caller.

DiffDownloadResponse

Backend response for a Diff download response. For details on the Scotty Diff protocol, visit http://go/scotty-diff-protocol.

JSON representation
{
  "objectLocation": {
    object (CompositeMedia)
  }
}
Fields
objectLocation

object (CompositeMedia)

The original object location.

DiffUploadRequest

A Diff upload request. For details on the Scotty Diff protocol, visit http://go/scotty-diff-protocol.

JSON representation
{
  "objectVersion": string,
  "objectInfo": {
    object (CompositeMedia)
  },
  "checksumsInfo": {
    object (CompositeMedia)
  }
}
Fields
objectVersion

string

The object version of the object that is the base version the incoming diff script will be applied to. This field will always be filled in.

objectInfo

object (CompositeMedia)

The location of the new object. Agents must clone the object located here, as the upload server will delete the contents once a response is received.

checksumsInfo

object (CompositeMedia)

The location of the checksums for the new object. Agents must clone the object located here, as the upload server will delete the contents once a response is received. For details on the format of the checksums, see http://go/scotty-diff-protocol.

DiffUploadResponse

Backend response for a Diff upload request. For details on the Scotty Diff protocol, visit http://go/scotty-diff-protocol.

JSON representation
{
  "objectVersion": string,
  "originalObject": {
    object (CompositeMedia)
  }
}
Fields
objectVersion

string

The object version of the object at the server. Must be included in the end notification response. The version in the end notification response must correspond to the new version of the object that is now stored at the server, after the upload.

originalObject

object (CompositeMedia)

The location of the original file for a diff upload request. Must be filled in if responding to an upload start notification.

ContentTypeInfo

Detailed Content-Type information from Scotty. The Content-Type of the media will typically be filled in by the header or Scotty's bestGuess, but this extended information provides the backend with more information so that it can make a better decision if needed. This is only used on media upload requests from Scotty.

JSON representation
{
  "bestGuess": string,
  "fromHeader": string,
  "fromFileName": string,
  "fromUrlPath": string,
  "fromBytes": string
}
Fields
bestGuess

string

Scotty's best guess of what the content type of the file is.

fromHeader

string

The content type of the file as specified in the request headers, multipart headers, or RUPIO start request.

fromFileName

string

The content type of the file derived from the file extension of the original file name used by the client.

fromUrlPath

string

The content type of the file derived from the file extension of the URL path. The URL path is assumed to represent a file name (which is typically only true for agents that are providing a REST API).

fromBytes

string

The content type of the file derived by looking at specific bytes (i.e. "magic bytes") of the actual file.

DownloadParameters

Parameters specific to media downloads.

JSON representation
{
  "allowGzipCompression": boolean,
  "ignoreRange": boolean
}
Fields
allowGzipCompression

boolean

A boolean to be returned in the response to Scotty. Allows/disallows gzip encoding of the payload content when the server thinks it's advantageous (hence, does not guarantee compression) which allows Scotty to GZip the response to the client.

ignoreRange

boolean

Determining whether or not Apiary should skip the inclusion of any Content-Range header on its response to Scotty.