I am looking into allowing users to upload PDF files (and later preview/download them back). I was looking around and it seems that ng-File-Upload is a popular directive to upload files since it supports many browsers.
I originally thought that I would have to convert my PDF's to blobs and store them in my SQL database and then convert back to PDF when given them the option to preview/download.
Playing around with ng-file-upload I see that when one uploads a file in the manner (taken from their sample page):
$scope.uploadFiles = function (file, errFiles) {
console.log(file);
$scope.f = file;
$scope.errFile = errFiles && errFiles[0];
if (file) {
file.upload = Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: { file: file }
});
file.upload.then(function (response) {
$timeout(function () {
file.result = response.data;
});
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
}, function (evt) {
file.progress = Math.min(100, parseInt(100.0 *
evt.loaded / evt.total));
});
}
}
}]);
and me checking out the file properties in the console I see a property called $ngfBlobUrl:
$ngfBlobUrl: "blob:http%3A//localhost%3A54170/0cc4b67a-9f6a-4833-acd0-7fd51e00996e
I am curious if anyone can give me any insight on how they generate this I assume in the file upload and if this is exactly what I need for my solution and if so can anyone point me to documentation on how I would go about converting it back to its original PDF form. I am trying to understand more how ng-file-upload works and whether it is a viable directive for my project or not.
Thanks