Giter Club home page Giter Club logo

angular-2-cloudinary's Introduction

Cloudinary Angular 2 Photo Album Project

Learn how to upload images in an Angular 2 app to Cloudinary and perform all sorts of transformation.

This sample project shows:

  1. How to use the Cloudinary Angular directives.
  2. How to upload files to Cloudinary in an unsigned manner, using an upload preset. The upload control is based on the open source file uploader ng2-file-upload
  3. How to use the dynamic list resource in order to maintain a short list of resources aggregated by tags.

Configuration

There are 2 settings you need to change for this demo to work. Open up app/config.ts and edit the following:

  1. cloud_name - Should be change to the cloud name you received when you registered for a Cloudinary account.
  2. upload_preset - You should first "Enable unsigned uploads" in the "Upload Settings" of your Cloudinary console and assign the resulting preset name to that field. Note, you may want to tweak and modify the upload preset's parameters.
  3. Additionally, in your Cloudinary console in the "Security Settings" section you should uncheck the "list" item.

Setup

Run npm install to install the required dependencies for this module.

Running

Run npm start to start the server and automatically open a browser and navigate to the application's url.

The application is deplyoed at http://localhost:3000/

Internals

This project is using SystemJS for bundling and serving the application.

The project creates a new NgModule, and depends on CloudinaryModule which is imported from the SDK module.

Sample main components

Routing

The application routes are defined in app/app.routing.ts

The application has 2 routes:

  • /photos - Presents a list of images tagged by myphotoalbum
  • /photos/new - Presents an upload control that allows uploading multiple files by a file input or drag-and-grop. Uploads have a dynamic progress bar. In addition it displays the details of successful uploads.

The default route is set to /photos.

Services

photo-album.service.ts retrieves the list of images from Cloudinary based on the myphotoalbum tag name.

Components

Photo list

Photo Upload

Important observations:

  • This implementation is based on an Angular file uploader.
  • Changes to the title field are propagated to the formData being sent in the upload request. This is meant to illustrate the possibility of attaching extra meta-data to each upload image.
  • The upload control uses the upload_preset we configured in Configuration step. This uses the settings defined on Cloudinary side to process the uploaded file.

Unsigned Upload

In order to add images to our photo album that would later be retrievable from the Cloudinary service we must select a tag which will serve as our source for the list. In this case myphotoalbum. While this tag can be set in the upload preset and remain hidden from the client side, in this sample we included it in the request itself to make this sample work without further configuration steps.

List Resource

Cloudinary supports a JSON list resource. This list represents all resources marked with a specific tag during upload (or later through other APIs). Whenever a new resource is uploaded with a tag, or an existing resource already tagged is deleted then the list is recalculated. This enables you to group a list of resources which can be retrieved by a single query. The size of the list is currently limited to 100 entires. Learn more

angular-2-cloudinary's People

Contributors

unicodeveloper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.