CollectionFS and CFS-S3 Meteor small help needed - javascript

I created a simple site to handle uploads with collectionFS, http://uploadapp.meteor.com/, when I click on upload it uploads the file to my AS3 bucket but if I click on the uploaded image in the site and copy url it gives me a local url example:
http://uploadapp.meteor.com/cfs/files/videos/tn877RSLTC2S6SnwG/download%20(1).jpeg?token=eyJhdXRoVG9rZW4iOiJHYkpZVkZ4V0dOLUlCQmJPbzdrdUxxS3VuQ3FDWDFBOUtSNzBBV1p3X0t3In0%3D
this means that the image is showing uploading to the mongodb and to as3?
how can I make it show and upload only and directly from AS3? (the images are stored to the as3 bucket so the upload is working)
The event handler for the upload form is :
Template.hello.events({
'change .fileInput':function(evt,tmpl){
FS.Utility.eachFile(event,function(file){
var fileObj = new FS.File(file);
Videos.insert(fileObj),function(err){
console.log(err);
}
})
}
});

The URL is simply a proxy to the actual image. The reason it's like this is it needs to sign the url to be displayed.
It's not actually on your mongodb its only on S3.

Related

How to skip crop function if the file is uploaded in .pdf format?

I'm creating a upload multiple file function using JavaScript. And I have problem when user are uploading their file in pdf extensions. Because when user first try to upload the document, if they are uploading picture they will have to crop their picture first then save it before the file got uploaded to the server. But now I got problem if the upload .pdf file. How to make the code skip the crop function if user are uploading other than .jpg ,.jpeg,.png file ?
The photo variable you set in the line let photo = $(this).prop("files")[0]; is an object of type File, which comes with some properties you can inspect, one of which being File.type
Something like the following should work:
let photo = $(this).prop("files")[0];
if (photo.type !== 'application/pdf') {
// file isn't a pdf, do the crop logic here
... cropping logic
}

Fineuploader : how to replace uploaded images?

I'm using fine uploader to upload images. After I upload an image, I need to be able to upload another image to replace the uploaded image before and only allow one image at one time. Is there any options for that or should I delete the upladed image before I start uploading the new one?
This is what I would do:
Set the multiple configuration option to false. This will be most helpful if you are using the UI built into the Fine Uploader library (and not a custom UI or React Fine Uploader. In that case, after a file has been submitted, subsequent files will "replace" that initial file in the UI.
Remove/replace the item on your server when handling the upload request if a file for that user already exists.
This is making a lot of assumptions as you have provided very little information about your situation or setup. This should get you started down the right path though.
End up deleting the uploaded images before uploading a new one:
onValidate: function() {
this.deleteFile(avatar_id);
}

Is it possible to detect file extension change with Javascript during HTML upload

I have a hypothetical question. I currently am using AngularJS in my application and I am using a third party module, ng-file-upload, for file uploads. Now obviously I can check the file extension of the uploaded file and exclude it / prevent it from being sent to the server should it be undesirable, for example I only wish to allow the upload of images and the user uploads a word document. However I was thinking. Should a malicious user change a file from say "nastyfile.exe" to "nastyfile.gif" the malicious file would pass my check/validation using the File.type property as the File.type would be image/gif. To my knowledge there is no way on the frontend I could check if the original file extension has been modified using JavaScript. Is this the case or is there a way to determine this?
Thanks in advance.
Try to create an image.
Then listen error & load event if load trigger, it is an image, else if error trigger it is not an image ;)
var img = new Image();
img.onerror = function() { /* not an image */ }
img.onload = function() { /* it is an image */ }
img.src = 'PATH/FILENAME';

Upload and Retrieve Image in Node.js?

I'm new to nodejs. I'm trying to upload an image to the server and store that image path in the localhost's PostgresSQL database as like this (myipaddress:3000/uploads/images/12345.png).
I Learned to upload an image to the server as specified in this link
But I would like to load that image url separately in mobile device or in image tag as follows <img src="myipaddress:3000/uploads/images/12345.png">
Thanks in advance and Can any one please provide suggestions to access an uploaded image with its url in my express application
Follow this (http://www.hacksparrow.com/handle-file-uploads-in-express-node-js.html) to upload an image to server in nodejs.
Once you followed. It will return response like this
File uploaded to: ./public/images/85d15c2f7e812a03faa44bdef0ce41f5.png - 278070 bytes
The response shows that your image is stored in the public/images directory
Image Name : 85d15c2f7e812a03faa44bdef0ce41f5.png
Image Path : ./public/images/85d15c2f7e812a03faa44bdef0ce41f5.png
You can load the image with the server ip by removing the public from the URL. Because we can directly access the content from the public directory without specifying public.
So the following link is enough to load the image from the URL.
your-local-ip:port/images/85d15c2f7e812a03faa44bdef0ce41f5.png
eg:
http://localhost:3000/images/85d15c2f7e812a03faa44bdef0ce41f5.png

Change file names before uploading with SWFUpload

I am using SWFUpload to allow users to upload multiple files in any browser. A user can provide custom file names for the files being uploaded. How can I iterate through all the queued files and update the name of the file to the custom name before the file is uploaded.
If I can't change the file name, how do I add a post parameter to each file being uploaded to make the change on the server side? I know how to add parameters for all files but how would I do it for each file?
You can't update the actual name of the file that gets sent in the POST body of the file upload because internally, SWFUpload is using a FileReference which doesn't let you change any of the file's properties before uploading it (and there's no way to get proper upload progress without using a FileReference to do the uploading, so this isn't something that can really be changed).
However, you should be able to add an extra POST parameter per file via the addFileParam function. Its signature is:
addFileParam(file_id:String, name:String, value:String):Boolean

Categories