2
0

storageAdapter.client.js 1007 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* global FS, _storageAdapters:true, EventEmitter */
  2. // #############################################################################
  3. //
  4. // STORAGE ADAPTER
  5. //
  6. // #############################################################################
  7. _storageAdapters = {};
  8. FS.StorageAdapter = function(name, options, api) {
  9. var self = this;
  10. // Check the api
  11. if (typeof api === 'undefined') {
  12. throw new Error('FS.StorageAdapter please define an api');
  13. }
  14. // store reference for easy lookup by name
  15. if (typeof _storageAdapters[name] !== 'undefined') {
  16. throw new Error('Storage name already exists: "' + name + '"');
  17. } else {
  18. _storageAdapters[name] = self;
  19. }
  20. // extend self with options and other info
  21. FS.Utility.extend(this, options || {}, {
  22. name: name
  23. });
  24. // XXX: TODO, add upload feature here...
  25. // we default to ddp upload but really let the SA like S3Cloud overwrite to
  26. // implement direct client to s3 upload
  27. };
  28. FS.StorageAdapter.prototype = new EventEmitter();