new_releases Aktualizacje: sprawdź
informacje o wersji, aby poznać nowe funkcje i aktualizacje.
Method: files.create
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Przesyła plik do użycia w wiadomościach z multimediami lub wiadomościach z kartą multimedialną.
Agent udostępnia adres URL lub plik binarny pliku oraz (opcjonalnie) adres URL odpowiedniego pliku miniatury.
Ważne: ze względu na prywatność i bezpieczeństwo użytkowników platforma RBM pobiera i przetwarza pliki multimedialne oraz PDF z podanych adresów URL, zanim przekaże je użytkownikowi. Zapobiega to śledzeniu agenta za pomocą niepowtarzalnych adresów URL. Dlatego nie przesyłaj dużej liczby niepowtarzalnych adresów URL. Platforma RBM nie obsługuje tego, niezależnie od tego, czy adresy URL wskazują na te same czy na różne pliki. Używaj tego samego adresu URL dla identycznych plików.
Platforma RBM przechowuje plik w pamięci podręcznej przez 60 dni i zwraca unikalną nazwę, której możesz użyć do identyfikacji pliku podczas wysyłania wiadomości do agenta.
Aby przesłać plik binarny, wyślij żądanie HTTP POST do identyfikatora URI przesyłania, pomiń pole fileUrl
w treści żądania JSON i jako treść żądania POST podaj plik binarny. Użyj na przykład parametru --upload-file
w curlu z pełną ścieżką do pliku binarnego.
Żądanie HTTP
- Identyfikator URI przesyłania, na potrzeby żądań przesyłania multimediów:
POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files
- Identyfikator URI metadanych, w przypadku żądań tylko z metadanymi:
POST https://rcsbusinessmessaging.googleapis.com/v1/files
Adres URL używa składni transkodowania gRPC.
Treść żądania
Treść żądania zawiera dane o następującej strukturze:
Zapis JSON |
{
"fileUrl": string,
"thumbnailUrl": string,
"agentId": string
} |
Pola |
fileUrl |
string
Opcjonalnie. Publicznie dostępny URL pliku. Podczas pobierania pliku platforma RBM określa typ MIME pliku na podstawie pola „content-type” w nagłówkach HTTP. RBM obsługuje obrazy, pliki audio, wideo i PDF. Obsługiwane typy treści graficznych: image/jpeg, image/jpg, image/gif, image/png. Obsługiwane typy treści audio: audio/aac, audio/mp3, audio/mpeg, audio/mpg, audio/mp4, audio/mp4-latm, audio/3gpp, application/ogg, audio/ogg. Obsługiwane typy treści wideo: video/h263, video/m4v, video/mp4, video/mpeg, video/mpeg4, video/webm. Obsługiwane typy treści PDF: application/pdf. Uwaga: adres URL pliku może zawierać 1 przekierowanie. Adresy URL przekierowanych plików muszą być dostępne publicznie. W metodzie CreateAgentMessageRequest nie są obsługiwane przekierowania dotyczące adresów URL plików.
|
thumbnailUrl |
string
Opcjonalnie. Dostępny publicznie adres URL miniatury odpowiadającej plikowi. Jeśli to pole nie jest ustawione, platforma RBM automatycznie wygeneruje miniaturę z pliku. Podczas pobierania pliku platforma RBM określa typ MIME pliku na podstawie pola „content-type” w nagłówkach HTTP. Obsługiwane typy treści graficznych: image/jpeg, image/jpg, image/gif, image/png.
|
agentId |
string
Wymagane. Unikalny identyfikator agenta.
|
Treść odpowiedzi
Zasób pliku o unikalnej nazwie, którego agent może używać do identyfikowania pliku podczas wysyłania wiadomości.
W przypadku powodzenia treść żądania zawiera dane o następującej strukturze:
Zapis JSON |
{
"name": string
} |
Pola |
name |
string
Przypisana przez serwer unikalna nazwa zasobu pliku, której agent może użyć do identyfikacji pliku podczas wysyłania wiadomości. Format to „files/{uid}”, gdzie {uid} to unikalny identyfikator.
|
Zakresy autoryzacji
Wymaga następującego zakresu OAuth:
https://www.googleapis.com/auth/rcsbusinessmessaging
Więcej informacji znajdziesz w OAuth 2.0 Overview.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-25 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-25 UTC."],[[["\u003cp\u003eThis process allows agents to upload files, including images, audio, video, and PDFs, for use in media or rich card messages, either by providing a public URL or the file's binary data.\u003c/p\u003e\n"],["\u003cp\u003eThe RBM platform handles file privacy and security by downloading and processing media files from provided URLs, preventing agent tracking via unique URLs, and caches the file for 60 days.\u003c/p\u003e\n"],["\u003cp\u003eThe file upload requires an HTTP POST request to either the upload URI \u003ccode\u003ehttps://rcsbusinessmessaging.googleapis.com/upload/v1/files\u003c/code\u003e or the metadata-only URI \u003ccode\u003ehttps://rcsbusinessmessaging.googleapis.com/v1/files\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe agent can provide a public \u003ccode\u003efileUrl\u003c/code\u003e, \u003ccode\u003ethumbnailUrl\u003c/code\u003e, and must include the \u003ccode\u003eagentId\u003c/code\u003e within the request body to upload files.\u003c/p\u003e\n"],["\u003cp\u003eUpon successful upload, the RBM platform returns a unique file name (\u003ccode\u003ename\u003c/code\u003e) that agents can use to reference the file in subsequent messages.\u003c/p\u003e\n"]]],[],null,["# Method: files.create\n\nUploads a file for use in media or rich card messages.\n\nThe agent provides the URL or binary of the file and (optionally) the URL of the corresponding thumbnail file.\n\nImportant: For user privacy and security, the RBM platform downloads and processes media and PDF files from the provided URLs before delivering them to the user. This prevents agent tracking by unique URLs. Therefore, do not submit a high volume of unique URLs. The RBM platform does not support this, whether the URLs point to the same or different files. Use the same URL for identical files.\n\nThe 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.\n\nTo upload a file binary, make an HTTP POST request to the Upload URI, omit the `fileUrl` field from the JSON request body, and specify the binary as the POST request body. For example, use the `--upload-file` cURL flag with the fully qualified file path of the binary file.\n\n### HTTP request\n\n- Upload URI, for media upload requests: \n `POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files`\n- Metadata URI, for metadata-only requests: \n `POST https://rcsbusinessmessaging.googleapis.com/v1/files`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------------------------------------------------|\n| ``` { \"fileUrl\": string, \"thumbnailUrl\": string, \"agentId\": string } ``` |\n\n| Fields ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fileUrl` | `string` Optional. Publicly available URL of the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. RBM supports image, audio, video, and pdf. Supported image content types: image/jpeg, image/jpg, image/gif, image/png. Supported audio content types: audio/aac, audio/mp3, audio/mpeg, audio/mpg, audio/mp4, audio/mp4-latm, audio/3gpp, application/ogg, audio/ogg. Supported video content types: video/h263, video/m4v, video/mp4, video/mpeg, video/mpeg4, video/webm. Supported pdf content types: application/pdf. Note: file URL can have 1 redirect. Redirected file URLs must be publicly accessible. Redirects are not supported for file URLs in CreateAgentMessageRequest. |\n| `thumbnailUrl` | `string` Optional. Publicly available URL of the thumbnail corresponding to the file. If this field is not set, then the RBM platform automatically generates a thumbnail from the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. Supported image content types: image/jpeg, image/jpg, image/gif, image/png. |\n| `agentId` | `string` Required. The agent's unique identifier. |\n\n### Response body\n\nA file resource with a unique name that an agent can use to identify the file when sending messages.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------|\n| ``` { \"name\": string } ``` |\n\n| Fields ||\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Server-assigned unique name of the file resource, which an agent can use to identify the file when sending messages. The format is \"files/{uid}\", where {uid} is a unique ID. |\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/rcsbusinessmessaging`\n\nFor more information, see the [OAuth 2.0 Overview](/identity/protocols/OAuth2)."]]