2020-06-12 12:28:29 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class File {
|
|
|
|
constructor($httpParamSerializer, vnToken) {
|
|
|
|
this.$httpParamSerializer = $httpParamSerializer;
|
|
|
|
this.vnToken = vnToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the full download path
|
|
|
|
*
|
|
|
|
* @param {String} dmsUrl The file download path
|
|
|
|
* @return {String} The full download path
|
|
|
|
*/
|
|
|
|
getPath(dmsUrl) {
|
|
|
|
const serializedParams = this.$httpParamSerializer({
|
2024-03-26 13:59:19 +00:00
|
|
|
access_token: this.vnToken.tokenMultimedia
|
2020-06-12 12:28:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return `${dmsUrl}?${serializedParams}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Downloads a file in another window, automatically adds the authorization
|
|
|
|
* token to params.
|
|
|
|
*
|
|
|
|
* @param {String} dmsUrl The file download path
|
|
|
|
*/
|
|
|
|
download(dmsUrl) {
|
|
|
|
window.open(this.getPath(dmsUrl));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
File.$inject = ['$httpParamSerializer', 'vnToken'];
|
|
|
|
|
|
|
|
ngModule.service('vnFile', File);
|