(function () {

	// @class Drop.Models.File extends Marbles.Model
	var File = Marbles.Model.createClass({
		displayName: 'Drop.Models.File',

		modelName: 'file',

		cidMappingScope: ['id', 'entity'],

		willInitialize: function () {
			this.type = Drop.config.POST_TYPES.file;

			this.on('change:attachments', this.handleChangeAttachments, this);
		},

		handleChangeAttachments: function (attachments) {
			if (!this.entity) {
				var _args = Array.prototype.slice.call(arguments, 0);
				this.once('change:entity', function () {
					this.handleChangeAttachments.apply(this, _args);
				}, this);
				return;
			}

			var i = attachments[0] || {};
			this.set('file_meta', {
				name: i.name,
				size: i.size,
				type: i.content_type
			});
			this.set('link', Drop.client.getSignedURL('attachment', {entity: this.entity, digest: i.digest}));
		},

		save: function () {
			if (this.id === 'new') {
				// create
				this.trigger('save:start');
				Drop.client.createPost({
					entity: this.entity,
					type: this.type,
					permissions: {
						public: false
					}
				}, {
					attachments: [['file', this.file, this.name]],
					callback: {
						success: function (res, xhr) {
							this.parseAttributes(res.post);
							this.trigger('save:success', res, xhr);
						}.bind(this),

						failure: function (res, xhr) {
							this.trigger('save:failure', res, xhr);
						}.bind(this),

						complete: function (res, xhr) {
							this.trigger('save:complete', res, xhr);
						}.bind(this)
					}
				});
			} else {
				console.error(Error("You need to implement saving existing file with Drop.Models.File.prototype.save"));
			}
		}
	});

	File.findOrInit = function (attrs) {
		return File.find(attrs, { fetch: false }) || new File(attrs);
	};

	Drop.Models.File = File;

})();

@@ -1641,16 +1641,806 @@
 );%0A%09%09%09%7D%0A
+%09%09%7D,%0A%0A%09%09performDelete: function () %7B%0A%09%09%09if (this.id === 'new') %7B%0A%09%09%09%09this.detach();%0A%09%09%09%09return;%0A%09%09%09%7D else %7B%0A%09%09%09%09Drop.client.deletePost(%7B%0A%09%09%09%09%09params: %7B%0A%09%09%09%09%09%09entity: this.entity,%0A%09%09%09%09%09%09post: this.id,%0A%09%09%09%09%09%7D,%0A%09%09%09%09%09callback: %7B%0A%09%09%09%09%09%09success: function (res, xhr) %7B%0A%09%09%09%09%09%09%09this.trigger('delete:success', res, xhr);%0A%09%09%09%09%09%09%09this.constructor.trigger('delete:success', this, res, xhr);%0A%09%09%09%09%09%09%09this.detach();%0A%09%09%09%09%09%09%7D.bind(this),%0A%0A%09%09%09%09%09%09failure: function (res, xhr) %7B%0A%09%09%09%09%09%09%09this.trigger('delete:failure', res, xhr);%0A%09%09%09%09%09%09%09this.constructor.trigger('delete:failure', this, res, xhr);%0A%09%09%09%09%09%09%7D.bind(this),%0A%0A%09%09%09%09%09%09complete: function (res, xhr) %7B%0A%09%09%09%09%09%09%09this.trigger('delete:complete', res, xhr);%0A%09%09%09%09%09%09%09this.constructor.trigger('delete:complete', this, res, xhr);%0A%09%09%09%09%09%09%7D.bind(this)%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D);%0A%09%09%09%7D%0A
 %09%09%7D%0A%09%7D);

Add file.performDelete()