Currently I am creating an application where I display an uploaded file from CollectionFS and display it using the CollectionFS url return. Locally the image loads and is displayed. However once I deploy the application to meteor.com the image url does not work. With the console indicating that the image path cannot be found.
CollectionFS returns this url for my image:
/cfs/contacts/75erhMtuwjn66fQH3_default1.png
Locally when I deploy the app I can see the image using in my .html:
img src="/cfs/contacts/75erhMtuwjn66fQH3_default1.png"
The specific code returned by CollectionFS is in the .html file and is being called client side:
{{cfsFileUrl "defaultHandler" fileId=fileId collection="Collection"}}
Locally I use this address as the source for the uploaded image in my html:
localhost:port/cfs/contacts/75erhMtuwjn66fQH3_default1.png
But when I attempt to view the image of the deployed app using the same procedure, it returns with an error of url not found:
http://host.meteor/cfs/contacts/75erhMtuwjn66fQH3_default1.png.com
A file is added on a click event client side .js:
'change .fileUploader': function (e) {
var files = e.target.files;
var fileName = files[0].name;
for (var i = 0, f; f = files[i]; i++) {
var k = ContactsFS.storeFile(f);
Session.set('fileID', k);
}}
Server side:
ContactsFS.fileHandlers({
default1: function(options) {
return {
blob: options.blob,
fileRecord: options.fileRecord // if no blob then save result in fileHandle (added createdAt)
};
}});
Then I can call the url in html with the given function from collectionFS documentation:
{{cfsFileUrl "default1" fileId=fileId collection="ContactsFS"}}
Once again the problem isn't generating the url. Both locally and once deployed the app displays a url. It is using the image url as the source for the image tag that is giving me the problem.
CollectionFS had a bug. I contacted the creator with the issue and it is now resolved in the collectionFS package. The report and closed issue can be found at:
https://github.com/raix/Meteor-CollectionFS/issues/85
Related
I have a problem with my project, I wanna to download a .txt file and save to any directory with Flutter WEB, I think I put the setup but It does not work. Now de .txt file display the content in the same tab of browser, but I want to download this file, here is my code:
void downloadFile(String url) {
html.AnchorElement anchorElement = new html.AnchorElement(href: url);
anchorElement.download = "plantilla_simulador.txt";
anchorElement.dispatchEvent(html.Event.eventType('MouseEvent', 'click'));
anchorElement.style.display = 'none';
anchorElement.click();
}
Perhaps you are trying to download file from another site.
Keep in mind that download attribute only works for same-origin URLs, or the blob: and data: schemes.
This code should download file:
html.AnchorElement(href: 'index.html')
..download = 'some_name.txt'
..style.display = 'none'
..click();
but this one should open file in browser:
html.AnchorElement(href: 'https://raw.githubusercontent.com/flutter/flutter/master/flutter_console.bat')
..download = 'some_name.txt'
..style.display = 'none'
..click();
I am currently using Vue js and trying to dynamically bind images that I'm getting from my database. I'm getting my path but the images aren't showing up. My front end is on localhost:8080 and my back end on localhost:3000.
In my app.js file, I'm establishing the the public folder as the static directory,
inside that folder I have my uploads directory which is where my images are being sent to.
app.use(express.static(path.join(__dirname, 'public')))
I'm sending my images there through multer:
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './public')
},
filename: function (req, file, cb) {
cb(null, new Date().toISOString() + file.originalname)
}
})
This is an example of how I'm seeing the image's source code popping up on the inspector.
src="public/uploads/2020-03-27T12:16:43.535Zaaa.jpeg"
I want to be able to display them dynamically in my components, but the images aren't showing up.
I'm also using Vuex and storing them in an object inside my states.
I think you should access your image using the full address
src="http://localhost:3000/uploads/2020-03-27T12:16:43.535Zaaa.jpeg"
I am using CKFinder 3 intergrated with CKEditor. Now, after resizing an Image and clicking on Choose Resized, I want to move/copy the resized image to another folder using javascript. I am able to get upto the following code.
CKFinder.start({
onInit: function (finder) {
finder.on('file:choose:resizedImage', function (event) {
var file = event.data.file;
var resizedData = file.get('imageResizeData');
var resized = file.get('imageResizeData').get('resized');
// Need help here to move the resized image to another folder.
});
}
});
NOTE: I am using ASP.NET Connector.
You can use command:send request to send CopyFiles request:
https://docs-old.ckeditor.com/ckfinder3/#!/api/CKFinder.Application-request-command_send
Parameters taken by CopyFiles can be found here:
https://docs-old.ckeditor.com/ckfinder3-net/commands.html#command_copyfiles
$("#downloadPdf").click(function () {
$(".img-indicator").hide();
html2canvas($("#frame"), {
onrendered: function (canvas) {
var image = canvas.toDataURL(
'image/png');
image = image.replace('data:image/png;base64,', '');
$("#generatedImg").val(image);
window.open(image);
}
});
});
I want to save this image to folder that is located on a server,
and I want to save that image with specific file name too.
JavaScript/jQuery run on the client side and cannot access the server folders. You need to create a web page on your server that will receive the file from your JavaScript/jQuery and saves it in the folder. Then you can call this page from your JavaScript/jQuery using $.ajax.
I'm building a web app with AngularJS that will allow users to upload their own images. Right now all of my data is text based, so I am storing the text based data in Firebase. As far as I know, Firebase can't store images. What I want to do is store the user generated images somewhere simple (I'm thinking Amazon S3 or even Dropbox) and then reference the images via unique URLs, which I would store as text in Firebase.
My questions:
Does this seem like a valid approach?
Any recommended services for hosting the images?
How to upload an image to the hosting service and get the image's unique URL?
Right now I am allowing users to upload images on the front end with the following code, just not sure what to do with the images once I have them. Would appreciate any help, I'm very new to this!
HTML
<output id="list"></output>
<input type="file" id="files" name="files[]" class="button" multiple />
Upload Pictures</i>
Angular Controller
$scope.getImages = function(){
$("input[type='file']").trigger('click');
}
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.
for (var i = 0, f; f = files[i]; i++) {
console.log(f);
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
// Render thumbnail.
var span = document.createElement('span');
span.innerHTML = ['<img class="thumb" src="', e.target.result,
'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById('list').insertBefore(span, null);
};
})(f);
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
You could use a service like Cloudinary to host images uploaded by your users. There are Angular directives that making using the service pretty easy. You will need a small server-side component to encrypt the upload parameters.
Look into Zapier integration with S3. The idea is that you setup a queue collection in firebase where you would create a new instance with the binary of the file data. Then zapier listens to for child_added on this queue collection and does it's magic (that you don't have to worry about) to upload your file to S3 bucket. After everything is finished, the instance in the queue is deleted... No server side needed with that, except there might be some fees...
Here is the link https://zapier.com/zapbook/amazon-s3/