curl --request POST \
--url https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
[
{
"name": "prueba.jpg",
"fileType": "IMAGE",
"checksumBase64": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=",
"contentType": "image/jpeg"
}
]
'import requests
url = "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files"
payload = [
{
"name": "prueba.jpg",
"fileType": "IMAGE",
"checksumBase64": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=",
"contentType": "image/jpeg"
}
]
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: 'prueba.jpg',
fileType: 'IMAGE',
checksumBase64: 'OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=',
contentType: 'image/jpeg'
}
])
};
fetch('https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'prueba.jpg',
'fileType' => 'IMAGE',
'checksumBase64' => 'OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=',
'contentType' => 'image/jpeg'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files"
payload := strings.NewReader("[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"mediaId": "4a2c1f7e-2f84-4a5f-bd2d-6b6b2f0c1234",
"presignUrl": {
"url": "https://s3.amazonaws.com/bucket/path/to/object",
"method": "PUT",
"headers": {
"Content-Type": "image/jpeg",
"x-amz-checksum-sha256": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo="
}
}
}
]{
"title": "Forbidden",
"status": 403,
"code": "BRIDGE_CORE_0301"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"title": "Too Many Requests",
"status": 429,
"code": "BRIDGE_RATE_LIMIT_0001"
}Criar uploads pré-assinados de arquivos
Carregue um anexo, como um PDF, uma imagem ou um documento, antes de criar uma mensagem. Esta operação retorna os dados de um PUT pré-assinado; os bytes do arquivo são enviados separadamente. Após o upload ser concluído, use o mediaId retornado na operação de envio. Siga Enviar um anexo para as etapas de checksum, upload e mensagem.
Gera URLs pré-assinadas para upload de arquivos (Presigned PUT). Valida a extensão, contentType e os limites por tipo. O checksum é obrigatório: envie o resumo SHA-256 em checksumBase64 (Base64). O upload deve incluir o cabeçalho x-amz-checksum-sha256 com o mesmo valor.
Para fazer upload dos arquivos, você DEVE usar a URL pré-assinada retornada com o método HTTP PUT. Envie o arquivo exatamente para a URL indicada, sem modificações, conforme exigido pelo AWS S3 para PUT com URL pré-assinada. Consulte a documentação oficial do AWS S3: Documentação do AWS S3 sobre Presigned PUT. Inclua todos os cabeçalhos obrigatórios indicados na resposta, por exemplo, ‘x-amz-checksum-sha256’ com o valor SHA-256 correto. A AWS rejeitará o upload se você não usar o método HTTP ou os cabeçalhos corretos.
| Tipo | Extensão | Tipo de conteúdo | Tamanho máximo |
|---|---|---|---|
| Imagem | .jpeg | image/jpeg | 16 MB |
| .jpg | image/jpeg | ||
| .png | image/png | ||
| .webp | image/webp | ||
| GIF | .gif | image/gif | 3 MB |
| .mp4 | video/mp4 | ||
| Vídeo | .avi | video/x-msvideo | 64 MB |
| .mov | video/quicktime | ||
| .mp4 | video/mp4 | ||
| Áudio | .m4a | audio/mp4 | 16 MB |
| .mp3 | audio/mpeg | ||
| .ogg | audio/ogg | ||
| .wav | audio/wav | ||
| Documento | .doc | application/msword | 100 MB |
| .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | ||
| application/pdf | |||
| .ppt | application/vnd.ms-powerpoint | ||
| .pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation | ||
| .txt | text/plain | ||
| .xls | application/vnd.ms-excel | ||
| .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
curl --request POST \
--url https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
[
{
"name": "prueba.jpg",
"fileType": "IMAGE",
"checksumBase64": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=",
"contentType": "image/jpeg"
}
]
'import requests
url = "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files"
payload = [
{
"name": "prueba.jpg",
"fileType": "IMAGE",
"checksumBase64": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=",
"contentType": "image/jpeg"
}
]
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: 'prueba.jpg',
fileType: 'IMAGE',
checksumBase64: 'OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=',
contentType: 'image/jpeg'
}
])
};
fetch('https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'prueba.jpg',
'fileType' => 'IMAGE',
'checksumBase64' => 'OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=',
'contentType' => 'image/jpeg'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files"
payload := strings.NewReader("[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"prueba.jpg\",\n \"fileType\": \"IMAGE\",\n \"checksumBase64\": \"OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo=\",\n \"contentType\": \"image/jpeg\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"mediaId": "4a2c1f7e-2f84-4a5f-bd2d-6b6b2f0c1234",
"presignUrl": {
"url": "https://s3.amazonaws.com/bucket/path/to/object",
"method": "PUT",
"headers": {
"Content-Type": "image/jpeg",
"x-amz-checksum-sha256": "OaZ+I0yqf3u3u5w8h0Y2v4e7W9vHh3zbn2mA2m1yPVo="
}
}
}
]{
"title": "Forbidden",
"status": 403,
"code": "BRIDGE_CORE_0301"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"title": "Too Many Requests",
"status": 429,
"code": "BRIDGE_RATE_LIMIT_0001"
}Parâmetros de caminho
Corpo
Esta página foi útil?

