|
1 | 1 | /*! |
2 | 2 | * AVOSCloud JavaScript SDK |
3 | | - * Version: 0.4.3 |
| 3 | + * Version: 0.4.4 |
4 | 4 | * Built: Mon Jun 03 2013 13:45:00 |
5 | 5 | * http://avoscloud.com |
6 | 6 | * |
|
13 | 13 | */ |
14 | 14 | (function(root) { |
15 | 15 | root.AV = root.AV || {}; |
16 | | - root.AV.VERSION = "js0.4.3"; |
| 16 | + root.AV.VERSION = "js0.4.4"; |
17 | 17 | }(this)); |
18 | 18 | // Underscore.js 1.4.4 |
19 | 19 | // http://underscorejs.org |
|
4113 | 4113 | } else if (typeof(File) !== "undefined" && data instanceof File) { |
4114 | 4114 | this._source = readAsync(data, type); |
4115 | 4115 | } else if(AV._isNode && Buffer.isBuffer(data)) { |
4116 | | - this._source = AV.Promise.as(data.toString('base64')); |
| 4116 | + this._source = AV.Promise.as(data.toString('base64'), guessedType); |
4117 | 4117 | this._metaData.size = data.length; |
4118 | 4118 | } else if (_.isString(data)) { |
4119 | 4119 | throw "Creating a AV.File from a String is not yet supported."; |
|
4268 | 4268 | mime_type: type, |
4269 | 4269 | metaData: self._metaData, |
4270 | 4270 | }; |
4271 | | - self._metaData.mime_type = type; |
| 4271 | + if(type && self._metaData.mime_type == null) |
| 4272 | + self._metaData.mime_type = type; |
4272 | 4273 | self._qiniu_key = key; |
4273 | 4274 | self._base64 = base64; |
4274 | 4275 | return AV._request("qiniu", null, null, 'POST', data); |
|
5578 | 5579 |
|
5579 | 5580 | AV.Object._extend = AV._extend; |
5580 | 5581 |
|
| 5582 | + /** |
| 5583 | + * Creates a new model with defined attributes, |
| 5584 | + * It's the same with |
| 5585 | + * <pre> |
| 5586 | + * new AV.Object(attributes, options); |
| 5587 | + * </pre> |
| 5588 | + * @param {Object} attributes The initial set of data to store in the object. |
| 5589 | + * @param {Object} options A set of Backbone-like options for creating the |
| 5590 | + * object. The only option currently supported is "collection". |
| 5591 | + * @return {AV.Object} |
| 5592 | + * @since v0.4.4 |
| 5593 | + * @see AV.Object |
| 5594 | + * @see AV.Object.extend |
| 5595 | + */ |
| 5596 | + AV.Object.new = function(attributes, options){ |
| 5597 | + return new AV.Object(attributes, options); |
| 5598 | + }; |
| 5599 | + |
5581 | 5600 | /** |
5582 | 5601 | * Creates a new subclass of AV.Object for the given AV class name. |
5583 | 5602 | * |
|
5643 | 5662 | var newArguments = [className].concat(AV._.toArray(arguments)); |
5644 | 5663 | return AV.Object.extend.apply(NewClassObject, newArguments); |
5645 | 5664 | }; |
| 5665 | + NewClassObject.new = function(attributes, options){ |
| 5666 | + return new NewClassObject(attributes, options); |
| 5667 | + }; |
5646 | 5668 | AV.Object._classMap[className] = NewClassObject; |
5647 | 5669 | return NewClassObject; |
5648 | 5670 | }; |
|
0 commit comments