Image Upload API

This is an optional upload service provided by Social Print Studio to make integration easier. It gives you a simple way to upload images and receive publicly accessible URLs — which is exactly what the Order Handoff API requires when submitting orders.

When to use this: If your application doesn't have its own backend or image hosting, or if you'd rather not manage file storage yourself, you can use this endpoint to upload customer photos directly to our S3 bucket. The returned publicUrl can then be passed straight into the projectData.photos array when calling the Add to Cart API.

If your app already hosts images at publicly accessible URLs (e.g. via your own S3 bucket, Cloudinary, Firebase Storage, etc.), you do not need this service — just pass those URLs directly to the Order Handoff API.


How it works

Upload files to S3 via presigned URLs. Supports images and other file types (PDFs, documents, etc.). Max file size is 50MB per file.

Endpoint

https://72yesvnolvy3nfva5gmjsqneye0knrvo.lambda-url.us-east-1.on.aws/

Usage

Step 1: Get Upload URL

const response = await fetch('https://72yesvnolvy3nfva5gmjsqneye0knrvo.lambda-url.us-east-1.on.aws/', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    filename: 'photo.jpg',        // required
    fileSize: 1234567,            // optional - enables 50MB validation
    contentType: 'image/jpeg',    // optional - auto-detected from filename
    folder: 'lambda-uploads'      // optional - defaults to 'lambda-uploads'
  })
});

const { uploadUrl, publicUrl } = await response.json();

Step 2: Upload File to S3

await fetch(uploadUrl, {
  method: 'PUT',
  headers: {
    'Content-Type': 'image/jpeg'
  },
  body: file  // raw File object
});

// File is now live at publicUrl

Complete Helper Function

async function uploadToS3(file, folder = 'lambda-uploads') {
  // Step 1: Get presigned URL from Lambda
  const response = await fetch('https://72yesvnolvy3nfva5gmjsqneye0knrvo.lambda-url.us-east-1.on.aws/', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      filename: file.name,
      fileSize: file.size,
      contentType: file.type,
      folder
    })
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message || 'Failed to get upload URL');
  }

  const { uploadUrl, publicUrl } = await response.json();

  // Step 2: Upload file directly to S3 using the presigned URL
  const uploadResponse = await fetch(uploadUrl, {
    method: 'PUT',
    headers: {
      'Content-Type': file.type
    },
    body: file
  });

  if (!uploadResponse.ok) {
    throw new Error(`S3 upload failed: ${uploadResponse.status}`);
  }

  return publicUrl;
}

// Usage
const publicUrl = await uploadToS3(fileFromInput);

Request Parameters

Required

ParameterDescription
filename The original filename (used for S3 key and content type detection)

Optional

ParameterDescription
fileSize File size in bytes. Recommended. Enables 50MB validation before upload.
contentType MIME type (e.g., image/jpeg, application/pdf, text/plain). Auto-detected from filename if not provided.
folder S3 subfolder path. Default: lambda-uploads

Recommended File Formats

JPG or PNG for photos. Some book products accept PDF files — check the specific product's JSON file in the product catalog for details.


Notes

Next step: submit the order

Once you have publicly accessible image URLs (either from this upload service or your own hosting), you're ready to submit an order. See the Order Handoff API to add products to the Social Print Studio cart.