npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ghost-storage-azure

v1.2.0

Published

Store content from ghost in azure file storage

Downloads

100

Readme

Ghost Storage Azure Adapter

npm version Build Status

This module is based on the original Ghost Azure Storage Adapter by Niyo, which allows you to store media files using Azure Storage and Azure Content Delivery Network resources instead of storing images on your local machine or local storage.

This updated module will upload your images to the specified blob storage with the file format <container-name>/images/image-name.jpg and does not use the date format <container-name>/images/<year>/month/date-hours-min_image-name.jpg by default (this setting is now configurable).

The adapter's upload process will automatically set CacheControl to 30 days, or more specifically: public, max-age=2592000 and set the appropriate contentType to be equal to the image type (default for Azure Storage is application/octet-stream so this adapter will override).

Features

  • Ghost version 2.x (not tested on previous Ghost versions)
  • Latest Azure Storage Client Library SDK
  • Image upload
  • Ability to upload in dated sub-directories (similar to Ghost default Local storage adapter <container-name>/images/YYYY/MM/dd-hh-mm_image-name.jpg)
  • Ability to upload images into a directory <container-name>/images/image-name.jpg
  • NEW (9/2019) - Upon upload, you will have your upload image available at your desired container path as well as size options to chose from. You can choose the following widths: 300, 600, 900. 1300 I.E:
    • Original image: without date enabled /container-name/images/image.png
    • Original image: with date enabled /container-name/images/YYYY/MM/dd-hh-mm_image-name.jpg
    • Original image size format(without date): /container-name/images/size/300/image.png
    • Original image size fromat (with date): /container-name/images/size/300/YYYY/MM/dd-hh-mm_image-name.jpg

In the above examples you would just change 300 to whichever width you wish to use out of the 4 available, or remove size/300 entirely to use the original image.

TO-DO Tasks

  • ~~Update CacheControl to optional parameter with configurable settings~~(Completed 9/2019 in 1.1.0-rc)
  • ~~Add in contentType based on image extension (Azure Storage defaults to application/octet-stream)~~ (Completed 9/2019 in 1.1.0-rc)
  • ~~Update adapter methods to support Ghost's added support of custom image sizes upon request.~~ (Completed in release Candidate 1.1.0-rc which now includes custom image sizes: 300, 600, 900, 1300)
  • Add in support for Azure Files (currently only works with blob storage)
  • Update documentation/readme to include how to use a Connection String from Azure KeyVault instead.

Installation

Run the following commands in the directory where Ghost is installed:

*nix

  • npm install ghost-storage-azure (note the absence of --save)
  • mkdir -p content/adapters/storage (make the adapters and storage folders if they do not already exist yet)
  • cp -vR node_modules/ghost-storage-azure content/adapters/storage/ghost-storage-azure (copy the module into the right location, the name must match)

powershell

  • npm install ghost-storage-azure (note the absence of --save)
  • mkdir content/adapters (make the adapters folder if it doesn't already exist yet)
  • mkdir content/storage/adapters (make the storage folder if it doesn't already exist)
  • cp -Recurse node_modules/ghost-storage-azure content/adapters/storage/ghost-storage-azure (copy the module into the right location)

alpine docker container

Add the following code snippet to your Dockerfile

# Add necessary packages for Sharp to work

RUN apk add --update --no-cache gcc g++ make libc6-compat python python3

RUN apk add vips-dev fftw-dev build-base --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community --repository https://alpine.global.ssl.fastly.net/alpine/edge/main

# Install Azure Storage

RUN npm install ghost-storage-azure
RUN cp -vR node_modules/ghost-storage-azure current/core/server/adapters/storage/ghost-storage-azure

Configuration

  1. Create new Azure Storage Account.
  2. [Optional] Create a new container. This will be created on demand if it does not already exist.
  3. Get the connection string to your storage account. You can find this in the preview portal, or from running the below Azure CLI commands:
  • az login (login to your azure account)
  • az account list -o table (list available azure subscriptions)
  • az account set --subscription "<subscription-id>" (set your az cli instance to use the appropriate subscription with the relevant storage account)
  • az storage account show-connection-string --resource-group <resource-group-name> --name <storage-account-name> (outputs a connection string to use, example is below)
	{
		"connectionString": "DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net;AccountName=<storage-account-name>;AccountKey=<storage-account-key>"
	}

Add storage block to file config.js in each environment as below:

    "storage": {
      "active": "ghost-storage-azure",
      "ghost-storage-azure": {
	"connectionString": "YourConnectionStringHere",
	"container": "YourOptionalContainerName",
	"cdnUrl": "YourCDNEndpointDomain",
	"useHttps" : "true", //Optional: CDN protocol. Defaults to http if omitted. Set to "true", to enable.
	"cacheControl" : "2592000", //Optional: cacheControl override. Defaults to 2592000 (30 days).
	"useDatedFolder" : true //Optional: Defaults to false. Set to `true` to enable.
       }
    },

Environment Variables

You can set your connection string as the Environment Variable AZURE_STORAGE_CONNECTION_STRING

Released under the MIT license.