jeanbmar

payload hash upload

by jeanbmar
Media & images
v?
MIT

Overview

Summary generated from the README

Adds a hash to the filenames of files uploaded to Payload upload collections, so each file version gets a unique URL suited to CDN caching. It is enabled as a plugin and configured per upload collection with a hash option. Resized images are handled too.

Features

  • Appends a content hash to uploaded filenames
  • Configurable hash algorithm compatible with Node.js crypto.createHash
  • Optional truncation for shorter hashes
  • Supports resized image variants
  • Enabled per upload collection through a hash option

Use cases

  • Improve CDN cache invalidation by giving changed uploads a new filename
  • Avoid filename collisions for files stored in the Payload database

From the author

Append a hash to upload filenames in Payload CMS, and optimize your CDN caching strategy

Installation

npm i payload-hash-upload

23

Stars

1

Forks

0

Open Issues

5 years ago

Last Updated

6

Weekly Downloads

v1.0.0

npm Version

7.0 KB

Unpacked Size

1

Dependencies

GitHub stars

230 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202623
Dec 4, 202623
Dec 3, 202623
Dec 2, 202623
Dec 1, 202623
Nov 30, 202623
Nov 29, 202623
Nov 28, 202623
Nov 27, 202623
Nov 26, 202623
Nov 25, 202623
Nov 24, 202623
Nov 23, 202623
Nov 22, 202623
Nov 21, 202623
Nov 20, 202623
Nov 19, 202623
Nov 18, 202623
Nov 17, 202623
Nov 16, 202623
Nov 15, 202623
Nov 14, 202623
Nov 13, 202623
Nov 12, 202623
Nov 11, 202623
Nov 10, 202623
Nov 9, 202623
Nov 8, 202623
Nov 7, 202623
Nov 6, 202623
Nov 5, 202623
Nov 4, 202623
Nov 3, 202623
Nov 2, 202623
Nov 1, 202623
Oct 31, 202623
Oct 30, 202623
Oct 29, 202623
Oct 28, 202623
Oct 27, 202623
Oct 26, 202623
Oct 25, 202623
Oct 24, 202623
Oct 23, 202623
Oct 22, 202623
Oct 21, 202623
Oct 20, 202623
Oct 19, 202623
Oct 18, 202623
Oct 17, 202623
Oct 16, 202623
Oct 15, 202623
Oct 14, 202623
Oct 13, 202623
Oct 12, 202623
Oct 11, 202623
Oct 10, 202623
Oct 9, 202623
Oct 8, 202623
Oct 7, 202623
Oct 6, 202623
Oct 5, 202623
Oct 4, 202623
Oct 3, 202623
Oct 2, 202623
Oct 1, 202623
Sep 30, 202623
Sep 29, 202623
Sep 28, 202623
Sep 27, 202623
Sep 26, 202623
Sep 25, 202623
Sep 24, 202623
Sep 23, 202623
Sep 22, 202623
Sep 21, 202623
Sep 20, 202623
Sep 19, 202623
Sep 18, 202623
Sep 17, 202623
Sep 16, 202623
Sep 15, 202623
Sep 14, 202623
Sep 13, 202623
Sep 12, 202623
Sep 11, 202623
Sep 10, 202623
Sep 9, 202623
Sep 8, 202623
Sep 7, 202623
Sep 6, 202623
npm weekly downloads

6+2 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20266
Dec 4, 20267
Dec 3, 20267
Dec 2, 20266
Dec 1, 202610
Nov 30, 202610
Nov 29, 20267
Nov 28, 20268
Nov 27, 20267
Nov 26, 20268
Nov 25, 20267
Nov 24, 20263
Nov 23, 20263
Nov 22, 20264
Nov 21, 20264
Nov 20, 20263
Nov 19, 20263
Nov 18, 20264
Nov 17, 20264
Nov 16, 20264
Nov 15, 20263
Nov 14, 20263
Nov 13, 20263
Nov 12, 20263
Nov 11, 20262
Nov 10, 20263
Nov 9, 20263
Nov 8, 20265
Nov 7, 20264
Nov 6, 20264
Nov 5, 20263
Nov 4, 20263
Nov 3, 20263
Nov 2, 20263
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20260
Oct 26, 20261
Oct 25, 20261
Oct 24, 20262
Oct 23, 20262
Oct 22, 20265
Oct 21, 20265
Oct 20, 20266
Oct 19, 20265
Oct 18, 20265
Oct 17, 20264
Oct 16, 20264
Oct 15, 20262
Oct 14, 20262
Oct 13, 20261
Oct 12, 20261
Oct 11, 20263
Oct 10, 20263
Oct 9, 20263
Oct 8, 20262
Oct 7, 20262
Oct 6, 20262
Oct 5, 20263
Oct 4, 20261
Oct 3, 20261
Oct 2, 20263
Oct 1, 20263
Sep 30, 20263
Sep 29, 20265
Sep 28, 20264
Sep 27, 20264
Sep 26, 20267
Sep 25, 20265
Sep 24, 20265
Sep 23, 20265
Sep 22, 20265
Sep 21, 20267
Sep 20, 20269
Sep 19, 20266
Sep 18, 20266
Sep 17, 20267
Sep 16, 20268
Sep 15, 20266
Sep 14, 20266
Sep 13, 20264
Sep 12, 20264
Sep 11, 20265
Sep 10, 20264
Sep 9, 20265
Sep 8, 20265
Sep 7, 20264
Sep 6, 20264

Each point is npm's rolling 7-day download count.

Health Score

41/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/393360382-root.svg)](https://payloaddirectory.dev/plugins/393360382-root)
HTML
<a href="https://payloaddirectory.dev/plugins/393360382-root"><img src="https://payloaddirectory.dev/badge/393360382-root.svg" alt="Payload Directory"></a>
Updated Aug 18, 2021Created Aug 6, 2021Published Aug 18, 2021

README

Append a hash to upload filenames in Payload CMS, and optimize your CDN caching strategy

This plugin ensures safe filenames with Payload CMS database.
Resized images are properly supported.

Install

npm install payload-hash-upload

Get Started

Enable plugin in Payload CMS config

import { buildConfig } from 'payload/config';
import hashUpload from 'payload-hash-upload';

export default buildConfig({
  // ...
  plugins: [
      hashUpload,
  ],
});

Configure your upload collections

const Media = {
  slug: 'media',
  upload: {
    staticURL: '/assets',
    staticDir: 'assets',
    hash: {
      algorithm: 'md5', // any algo compatible with Node.js crypto.createHash
      truncate: 10, // optional, for shorter hashes
    },
  },
};

export default Media;

Result

chnux.png -> chnux.9cdfb439c7.png

Similar plugins