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:
{ i m a g e _ r e s i z e s : [ { n a m e : ' h a l f x h a l f ' , w i d t h : 50 , h e i g h t : 50 , r e s i z e _ t y p e : ' % ' } / / < - r e s i z e s t h e i m a g e o n l y i f b o t h o f i t s d i m e n s i o n s a r e l e s s t h a n t h e g e o m e t r y s p e c i f i c a t i o n
/ / > - t o c h a n g e t h e d i m e n s i o n s o f t h e i m a g e o n l y i f i t s w i d t h o r h e i g h t e x c e e d s t h e g e o m e t r y s p e c i f i c a t i o n
/ / % - s p e c i f y a p e r c e n t a g e w i d t h o r h e i g h t i n s t e a d
, { n a m e : ' 100 x 100 ' , w i d t h : 100 , h e i g h t : 100 , r e s i z e _ t y p e : ' ! ' } / / ! - o v e r r i d e p r o p o r t i o n
, { n a m e : ' 640 x ' , w i d t h : 640 , h e i g h t : null }
, { n a m e : ' x 500 ' , w i d t h : null , h e i g h t : 500 }
, { n a m e : ' t h u m b ' , w i d t h : 200 , h e i g h t : 200 , r e s i z e _ t y p e : ' t h u m b ' , b g c o l o r : ' t r a n s p a r e n t ' }
}
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 ] ) ;
} ;
}
} ) ;