Download attachment
Download attachment: downloadAttachment in the TypeScript, Python, Rust and Go clients.
GET /v1/projects/{id}/attachments/{attachmentId}/content
Downloads an Attachment's bytes. If unavailable after ten seconds, returns ATTACHMENT_NOT_READY with Retry-After: 5.
photon.projects.downloadAttachment(input: DownloadAttachmentInput, options?: RequestOptions): Promise<DownloadAttachmentOutput>photon.projects.download_attachment(input: DownloadAttachmentInput, *, options: RequestOptions | None = None) -> bytesclient.download_attachment(attachment_id: String, id: String).await -> Result<ResponseValue<bytes::Bytes>, Error<DownloadAttachmentError>>client.Projects.DownloadAttachment(ctx context.Context, params *DownloadAttachmentParams, opts ...RequestOption) (*BinaryResponse, error)import { Photon } from "@photon-ai/api";
const photon = new Photon({
headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.downloadAttachment({
path: {
attachmentId: "attachmentId",
id: "id",
},
});import os
from photon_api import Photon
from photon_api.rpc_generated import DownloadAttachmentInput
photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.projects.download_attachment(
DownloadAttachmentInput.model_validate({
"path": {
"attachmentId": "attachmentId",
"id": "id",
},
})
)use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};
let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
.credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
.build()?;
let result = client
.download_attachment("attachmentId".to_owned(), "id".to_owned())
.await
.map_err(|error| format!("{error:?}"))?
.into_inner();import (
"context"
"os"
photonapi "github.com/photon-hq/api/packages/go"
)
ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
result, err := client.Projects.DownloadAttachment(ctx, &photonapi.DownloadAttachmentParams{
AttachmentID: "attachmentId",
ID: "id",
})
if err != nil {
return err
}
_ = resultParameters
Returns
200 The Attachment's raw file bytes. Content-Type identifies the media type of the response. The */* body as bytes.
Headers: Content-Disposition. The raw response carries these headers; see Raw responses.