5.1.0 • Published 10 months ago

@k6-contrib/fields-s3-images v5.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

S3 Sharp Image Optimized Field

import { S3ImagesConfig, s3Images } from '@k6-contrib/fields-s3-images';
import 'dotenv/config';

const s3sConfig: S3sConfig = {
  bucket: process.env.S3_BUCKET, // name of bucket
  folder: process.env.S3_PATH,
  baseUrl: process.env.S3_BASE_URL, // if provided the url is not compouted from endpoint and folder, rather use this as `${baseUrl}/${filename}`
  s3Options: {
    accessKeyId: process.env.S3_ACCESS_KEY_ID,
    secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
    endpoint: process.env.S3_ENDPOINT, // use region for aws, endpoint for s3 compatible storage
  },
  sizes: {
    sm: 360,
    md: 720,
    lg: 1280,

    // optional
    // if specified, a base64 data url will be generated from an image resized to this number of pixels
    // see: https://nextjs.org/docs/api-reference/next/image#blurdataurl for potential uses
    base64: 10,
  },
  uploadParams() {
    return {
      ACL: 'public-read', // needed to make it public
    };
  },
};

const Post = list({
  fields: {
    title: text({ validation: { isRequired: true } }),
    content: text(),
    image: s3Image({ s3Config }),
    file: s3File({ s3Config }),
  },
});
query {
  images {
    image {
      id
      width
      height

      # defaults to size: md
      url

      lgUrl: url(size: lg)

      # base64 data url (if enabled via config, otherwise `null`)
      placeholderUrl: url(size: base64)

      # img html element compatible srcset
      srcSet(sizes: [sm, md, lg])
    }
  }
}
5.1.0

10 months ago

5.0.0

1 year ago

4.0.0

1 year ago

3.0.0

2 years ago

1.2.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.3.1

3 years ago

0.1.0

3 years ago

0.1.1-dev0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago