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"
}Crear cargas prefirmadas de archivos
Carga un archivo adjunto, como un PDF, una imagen o un documento, antes de crear un mensaje. Esta operación devuelve los datos de un PUT prefirmado; los bytes del archivo se cargan por separado. Cuando la carga termine correctamente, utiliza el mediaId devuelto en la operación de envío. Sigue Enviar un archivo adjunto para los pasos de suma de comprobación, carga y mensaje.
Genera URL prefirmadas para cargar archivos (Presigned PUT). Valida la extensión, contentType y los límites por tipo. La suma de comprobación es obligatoria: envía el resumen SHA-256 en checksumBase64 (Base64). La carga debe incluir la cabecera x-amz-checksum-sha256 con el mismo valor.
Para cargar los archivos, DEBES utilizar la URL prefirmada devuelta con el método HTTP PUT. Carga el archivo exactamente en la URL indicada, sin modificaciones, tal como exige AWS S3 para un PUT con URL prefirmada. Consulta la documentación oficial de AWS S3: Documentación de AWS S3 sobre Presigned PUT. Incluye todas las cabeceras obligatorias indicadas en la respuesta, por ejemplo, ‘x-amz-checksum-sha256’ con el valor SHA-256 correcto. AWS rechazará la carga si no utilizas el método HTTP o las cabeceras correctos.
| Tipo | Extensión | Tipo de contenido | Tamaño máximo |
|---|---|---|---|
| Imagen | .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 | ||
| Audio | .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 ruta
Cuerpo
¿Esta página le ayudó?

