Closed myuid closed 2 years ago
@myuid
Drag the video directly into Chrome and play it without any problems, and write the file successfully using the following methods import fs from 'fs'; import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});
fs.readFile('/data/imgs/sample.png', (error, data) => {
if (error) {
throw error;
} else {
Images.write(data, {
fileName: 'sample.png',
fileId: 'abc123myId', //optional
type: 'image/png'
}, (writeError, fileRef) => {
if (writeError) {
throw writeError;
} else {
console.log(${fileRef.name} is successfully saved to FS. _id: ${fileRef._id}
);
}
});
}
});
But the file cannot be played (VLC and Chrome), then add the following file to FileCollection
import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});
Images.addFile('/var/www/files/sample.png', { fileName: 'sample.png', type: 'image/png', fileId: 'abc123AwesomeId', meta: {} });
The URL generated using the following method cannot be played back const fileRef = Images.collection.findOne({}); Images.link(fileRef);
The operation of the pictures is normal
@myuid I recommend you trying to add ?play=true
get query at the end of file's URL. Let me know if it helps
Feel free to reopen it in case if the issue is still persists on your end.
The H264 MP4 video file I generated by FFMPEG can not play properly if I write() the file, I use addFile() to write relevant data in the collection, and the link generated by link() can not play normally in Chrome, I don't know why?