"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 |