# contentitems

> Basic implementation of local/S3 images/audio/video storage with ability to create resized copied of uploaded images.

Latest version **0.0.52** (published 2017-07-04) · 0 weekly downloads

## Install

```sh
npm install contentitems
pnpm add contentitems
yarn add contentitems
bun add contentitems
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.52 |
| Published | 2017-07-04 |
| First published | 2015-06-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| Author | Igor Sheyko |
| Maintainers | ias |
| Keywords | files storage |

## Links

- npm: https://www.npmjs.com/package/contentitems
- npm.io page: https://npm.io/package/contentitems

## Dependencies (6)

- [q](https://npm.io/package/q.md) ~1.4.1
- [gm](https://npm.io/package/gm.md) ~1.21.1
- [aws-sdk](https://npm.io/package/aws-sdk.md) ~2.2.30
- [fs-extra](https://npm.io/package/fs-extra.md) ~0.26.4
- [sync-exec](https://npm.io/package/sync-exec.md) ~0.6.2
- [multiparty](https://npm.io/package/multiparty.md) ~4.1.2

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.0.52 (latest) — 2017-07-04
- 0.0.50 — 2017-06-10
- 0.0.49 — 2017-05-08
- 0.0.48 — 2017-05-08
- 0.0.47 — 2017-05-07
- 0.0.46 — 2016-11-22
- 0.0.45 — 2016-10-31
- 0.0.44 — 2016-08-19
- 0.0.43 — 2016-08-10
- 0.0.42 — 2016-07-28
- 0.0.40 — 2016-06-07
- 0.0.39 — 2016-05-13
- 0.0.38 — 2016-05-04
- 0.0.37 — 2016-05-04
- 0.0.36 — 2016-04-25
- … 33 more at https://npm.io/package/contentitems/versions

## README

# ContentItems [![Build Status]

`ContentItems` storage for Images/Audio/Video

## Setting up the client

The constructor of the `contentitems` client take 2 different arguments `ServerConfig` (local storage or S3 storage) and `options`. Syntax:

Example of config for the Local Storage:
{type: 'local', dir:  '../contentitems/'}

Example of config for the Amazon S3 Storage:
{type: 's3', bucket:  'contentitems_1433571935989', credentials: {accessKeyId: 'your_accessKeyId', secretAccessKey: 'your_secretAccessKey'}}


Image resizing:
  * if you do not need image resizing, just leave image_resizes empty (e.e. {image_resizes:[]})
  * otherwise fill it:
``` json
    {image_resizes: [{name: 'halfxhalf', width: 50, height: 50, resize_type: '%'}           //  < - resizes the image only if both of its dimensions are less than the geometry specification
                                                                                            //  > -  to change the dimensions of the image only if its width or height exceeds the geometry specification
                                                                                            //  % - specify a percentage width or height instead
                    , {name: '100x100', width: 100, height: 100, resize_type: '!'}          //  ! - override proportion
                    , {name: '640x', width: 640, height: null}
                    , {name: 'x500', width: null, height: 500}
                    , {name: 'thumb', width: 200, height: 200, resize_type: 'thumb', bgcolor: 'transparent'}
    }
```
   

``` js
var ContentItems = require('contentitems');
    var contentitems = new ContentItems({type: 'local', dir:  '../contentitems/'}, {image_resizes: [{name: '250x250', width: 250, height: 250, resize_type: '!'}
                                                                                                   ,{name: '640x', width: 640, height: null}
                                                                                                   ,{name: 'thumb', width: 200, height: 200, resize_type: 'thumb', bgcolor: 'transparent'}
                                                                                                    ]
    });
    contentitems.upload_content_item(req, function(err, data){
        if(typeof data.data != 'undefined' && typeof data.data.content_items != 'undefined'){
            for(i in data){
                console.log('RESULT['+i+']:', data[i].result);
            }
        }
    });
    
    contentitems.get_content_item_info(req, function(err, data){
        if(typeof data.data != 'undefined' && typeof data.data.content_items != 'undefined'){
            for(i in data.data.content_items){
                console.log('RESULT['+i+']:', data.data.content_items[i]);
            };
        }
    });
    
    contentitems.delete_content_item(req, function(err, data){
        if(typeof data.data != 'undefined' && typeof data.data.content_items != 'undefined'){
            for(i in data.data.content_items){
                console.log('RESULT['+i+']:', data.data.content_items[i]);
            };
        }
    });
```

---
_Source: https://npm.io/package/contentitems · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
