Added support for png and check to see if the image is ready

resolves #3206
This commit is contained in:
Oleksandr Zhurbenko 2016-07-08 16:11:52 -07:00
parent 1d451f1e09
commit 7948571525

View File

@ -4,13 +4,20 @@ import Slides from '/imports/api/slides';
export function addSlideToCollection(meetingId, presentationId, slideObject) {
const url = Npm.require('url');
const http = Npm.require('http');
const imageUri = slideObject.svg_uri != null ? slideObject.svg_uri : slideObject.png_uri;
if (Slides.findOne({
meetingId: meetingId,
'slide.id': slideObject.id,
}) == null) {
const options = url.parse(slideObject.svg_uri);
const options = url.parse(imageUri);
http.get(options, Meteor.bindEnvironment(function (response) {
let contentType = response.headers['content-type'];
if (!contentType.match(/svg/gi) && !contentType.match(/png/gi)) {
console.log(`Slide file is not accessible or not ready yet`);
console.log(`response content-type`, response.headers['content-type']);
return;
}
let chunks = [];
response.on('data', Meteor.bindEnvironment(function (chunk) {
chunks.push(chunk);