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

ngx-aws-s3-private-image-mng

v2.1.0

Published

An Angular library to manage, add, remove and select images from a private AWS S3 bucket

Downloads

23

Readme

Angular AWS S3 Private Image Manager

An Angular image gallary to manage, add, delete, and select images that are stored in a private S3 bucket.

In todays environments static resources such as images are mostly stored off your app server such as AWS S3 buckets. Store the pathes to those assets in your DB or such, and access to those files is seamless. However, in many cases or requirements those bucket must be private, which make access to those files from the browser more complex.

This is an Angular library which implements the client side feature to view, add, select, and delete images from a private S3 bucket. We will document the needed sevre side and DB api's needed to support this feature.

Besides beeing an Angular library, this library has no dependencies (only HttpClientModule). So can be used in any Angular project.

Client Side

Install the library.

npm install  ngx-aws-s3-private-image-mng --save

Usage In your ngModule

import { AngularAWSPrivateImageManagerModule } from 'ngx-aws-s3-private-image-mng';
...
@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    AngularAWSPrivateImageManagerModule
  ]
})

In your Component .ts file

import { ApiPaths, GalleryImage } from 'ngx-aws-s3-private-image-mng';

@Component({
...
})
export class MyComponent implements OnInit {
  
  // Server APIs that get Imported into the library
  apis: ApiPaths = {
    getImages: '/path/to/getImages/api/',
    upload: '/path/to/upload/api',
    delete: '/path/to/delete/api'
  }

In your Compoent .html file

 <any-el [s3imgsTrigger]="apis" [disableDelete]="true" (s3imgSelected)="myFunc($event)"></any-el>

@Input() disableDelete - whether the delete image option is disabled. (defualt is falue). The s3imageSelected event is triggered when an image is selcted from the gallery. The $event emited by this event will be an object with the shape of GalleryImage. ({id: string, url: string, thumbnailUrl: string}).

Server Side

Since the bucket is private your server will have to generate AWS presigned urls to view the images. Your server will need to save the original file and a thumbnail version of the file. (when viewing the list of images only the thumbnail will be downloaded)

Database

A table or collection with the following fields:

  • id
  • key: String - The S3 path and name of the image. (someFolder/someFloder/nameOfFile)
  • size: Int - The size of the original image.
  • tag: String - Tag name of the image for searching. (this comes from client when uploading a new file)

Server

Your server will need the following API's

  • POST. Takes an image file and a tag name (The payload will be a formData object with fields tag and file). Create a thumbnail version and save original and thumbnail images to S3 bucket (apent the string "thumbnail" to the thumbnail version). Save to DB size, tag and key (The key is the S3 path and name of the image. (someFolder/someFloder/nameOfFile).

  • GET. Takes an optional (url) tag param. Return an array of image objects. The serve will get the rows from the DB (Filter the results by the optional tag field.), generate AWS presigned URL'S for each image and thumbnail and return to client along with tag, size, and key for each image. Each object will have the shape of {id: "theDBid", key: "the KeyFieldFromDB",size: "theSizeFieldFromDB", tag: "theTagFieldFromDB", thumbnail: "thePathOfFileThumnail", thumbnailUrl: "theGeneratedPresigendURLofThumnail", url: "theGeneratedPresigendURLofOriginal" }.

  • DELETE. API with id route param of the image id to delete. Delete form DB and from S3 bucket (Don't forget to delete original and thumbnail).