blob: d04b08d10c550e7ad32e2a9181e84a5b67c5f28f [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class FileReaderService {
constructor() { }
// reads file from filesystem.
public readFile(inputFile: File) {
const reader = new FileReader();
return new Promise((resolve, reject) => {
reader.onerror = () => {
reader.abort();
reject(new DOMException('Problem parsing input file.'));
};
reader.onloadend = () => resolve(reader.result);
reader.readAsDataURL(inputFile);
});
}
}