All files / src BinaryField.js

0% Statements 0/14
0% Branches 0/6
0% Functions 0/6
0% Lines 0/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                                       
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class BinaryField {
    constructor(_mediaResourceObject, _contentReference, _fieldSettings) {
        this._mediaResourceObject = _mediaResourceObject;
        this._contentReference = _contentReference;
        this._fieldSettings = _fieldSettings;
        this.SaveBinaryFile = (file) => this._contentReference.GetRepository().UploadFile({
            File: new File([file], this._contentReference.Name),
            Parent: { GetFullPath: () => this._contentReference.ParentContentPath, Path: this._contentReference.ParentPath },
            PropertyName: this._fieldSettings.Name,
            ContentType: this._contentReference.constructor,
            Overwrite: true,
        });
        this.SaveBinaryText = (text) => this.SaveBinaryFile(new File([text], this._contentReference.Name || 'File'));
    }
    GetDownloadUrl() {
        if (!this._mediaResourceObject || typeof this._mediaResourceObject !== 'object') {
            return `/binaryhandler.ashx?nodeid=${this._contentReference.Id}&propertyname=${this._fieldSettings.Name}`;
        }
        return this._mediaResourceObject.__mediaresource.media_src;
    }
    GetMediaResourceObject() {
        return Object.assign({}, this._mediaResourceObject);
    }
}
exports.BinaryField = BinaryField;
//# sourceMappingURL=BinaryField.js.map