Skip to main content
export interface Attachment {
  fileName: string;
  bucket: string;
  region: string;
  endpoint?: string;
  suggestedFileName: string;
  fileType?: AttachmentType;
  toJSON(): Record<string,
  string>;
  toDict(): Record<string,
  string>;
  getS3Key(): string;
  getFilePath(): string;
  getSignedUrl(expiration?: number): Promise<string>;
}
Represents an uploaded file stored in AWS S3 with metadata and utility methods. This interface provides a structured way to handle file information for files stored in S3, including methods for generating presigned URLs, serialization, and accessing file metadata.

Examples

import { uploadFileToS3 } from "@intuned/browser";
export default async function handler(params, page, context){
// Typically returned from uploadFileToS3 or saveFileToS3

const uploadedFile: Attachment = await uploadFileToS3({
  file: myFile,
  configs: s3Config
});

// Access file properties
console.log(uploadedFile.fileName); // "documents/report.pdf"
console.log(uploadedFile.suggestedFileName); // "Monthly Report.pdf"

// Get a presigned URL for download
const downloadUrl = await uploadedFile.getSignedUrl(3600); // 1 hour

// Convert to dictionary for storage or API responses
const fileDict = uploadedFile.toDict();
}