JedWatson/keystone — pull request #230 by jbalde (2014-03-12 17:45:50+00:00)
Title: New Azure Storage Blob File field.

Azure Storage is a cloud storage like S3 in Azure Cloud. This field is based in S3 field with Azure client.

Configure with

keystone.set('azurefile config', { account: 'storage account' /* not user account */, key: 'secret api key' });

Or with environment

process.env.AZURE_STORAGE_ACCOUNT and process.env.AZURE_STORAGE_ACCESS_KEY

The default container (like bucket in S3 is a keystone).

Model only need defined the type

simpleModelProperty: { type: Types.AzureFile }

but cant defiend filenameFormatter and containerFormatter to format the name of the file and the container name is are diferent of default 'keystone' container.

simpleModelProperty: { type: Types.AzureFile }
//the next property defined the upload filename as itemID with extension format a name like 5315f3a519e382ee32b80472.pdf
//with container formatter can define a custom container name with item and filename. For example can create a custom container with only images or with a property of model.
customModelProperty: { type: Types.AzureFile, filenameFormatter: function(item, filename) { return item._id + require('path').extname(filename); }, containerFormatter: function(item, filename) { return (item.cdnName != "") ? item.cdnName : 'mycdn'; } },

If configure the variables with test values the resultant urls are like:

keystone.set('azurefile config', { account: 'myaccount' /* not user account */, key: 'secret api key' });

TEST SIMPLE: http://myaccount.blob.core.windows.net/keystone/my-file-name.pdf
TEST CUSTOM: http://myaccount.blob.core.windows.net/mycdn/5315f3a519e382ee32b80472.pdf