Correct way to upload multiple files - http

I am writing a web app, and not sure about how to upload multiple images. I want to make sure that either all images are uploaded successfully, or none of them.
One way is to upload them simultaneously in several thread. However, if one of the uploading process fails, it is difficult to cancel other process and remove uploaded images.
The solution I come up with is to combine the multiple files into a bigger file using some separator, and then server then separates it into original files.
Is my solution appropriate? Or are there any better solutions?

You will need some functional to check all files after all files have been uploaded. The simplest way - using standart form/multipart POST with all files in one request. But of course it is not so elegant. Another way - using one of popular and well tested plugin, for example - https://github.com/blueimp/jQuery-File-Upload

Related

Safety of uploadFile in ShinyApp

There is a way to take files from user via Shiny app using inputFile. I would like to take pdf files from user. How could i make it secure ? I mean that user will not have possibility to upload 200+ gigabyte file or virus etc. Other possibly concerns or your own experience would be very helpful,like where to store those files, how collect them and so on
This question is more about sanitizing your inputs than it is about shiny. However, it is still valid and an important aspect to consider whenever you allow file uploads in your application.
One way would be to only allow PDFs, but inputFile doesn't really support limiting which files to upload (yet). However, you can restrict the size of your file uploads by placing this at the top of your app.R-file: options(shiny.maxRequestSize = 30*1024^2). This equates to 30 MB, as demonstrated in this vignette.
This is obviously not the ideal solution. One alternative might be to use a HTML method for uploading files, and then handling those passing those files along to Shiny with some Javascript.

Multiple pdf files in one embed

I need your help over a problem I have. Actually, I have a page with a simple embed which displays a PDF file.
I got a request to add another PDF file to the same embed (or at least to do something which would look like it).
I searched some solutions and not finding a simple one, I'm thinking about using iTextSharp to merge both files (by getting their stream from their url), merging them into a new pdf file and display this resulting file into the embed.
But I'm just telling myself it's a bit too much for such a simple modification... And so I'm here asking you if someone would have a better idea ? From what I searched on stackoverflow and google it looks like I will have to take the merge solution but hey, we never know '^^
A simpler option would be to merge the two PDF files using either a free online tool or Adobe Combine Files option and then adding that newly combined PDF to your site. Unless I am missing something, there is no real reason or benefit to do this using code.

How do I use Atom's linter-jshint when code is split up across multiple files?

I'm writing a single-page JavaScript application and I'm using Atom as my text-editor. (It's an Electron application, but that's besides the point.)
I'm also using the linter-jshint plugin for Atom. This is great, as it shows immediately in the text-editor when I make a typo in a variable, among other useful things.
Lately, my app has been getting very long. Naturally, I want to try and split it up across multiple files. After doing some research on StackOverflow, I've determined that I can use Grunt to automatically concatenate JavaScript files together. This is great because I don't have to refactor my code - I can just copy paste my existing functions into separate files. Easy!
However, once I do this, Atom fills up with warnings and errors from JSHint, because it can't find variables and functions that are located in the other files!
Now, I could just abandon the JHint plugin in Atom altogether and use the JSHint plugin for Grunt after the concatenation has already occured. But that sucks! I want the code that I'm going to be writing to be checked on the fly like a real IDE.
Is there a way to tell Atom/JSHint to assume that a bunch of JavaScript files will all be concatenated together? Or am I just approaching this problem completely wrong?
You can split your electron application with Node Common Modules, and use require('./state.js'); within your application.
Although I don't use Atom, that should allow for it to understand how you're using your variables and functions in other files.
Also this should eliminate your need for concatenation as the single-page app will have all it's dependencies accounted for.

Capture many .png files over HTTP that are named as .htm?

I want to download a large number of .png files that have .htm file extensions. I've tried a some WinPcap-based utilities, but none of them pick up the files I need. The utilities I have tried are called York, EtherWatch and Pikachu2. I've also tried using a Firefox extension called Save Images - which was too buggy to be useful - and I've tried looking in the browser cache. This last approach works, but it has a problem...
...I need at least the last 30 characters of the file names to be maintained so that I know which image is which.
Does anyone know how I can get this done?
you can use downthemall to download all the images, and rename the file extension programmatically

Drupal - Attach files automatically by name to nodes

i need better file attachement function. Best would be that if you upload files to FTP and have a similar name as the name of the node (containing the same word), so they appear under this node (to not have to add each file separately if you need to have more nodes below). Can you think of a solution? Alternatively, some that will not be as difficult as it always manually add it again.
Dan.
This would take a fair bit of coding. Basically you want to implement hook_cron() and run a function that loops through every file in your FTP folder. The function will look for names of files that have not already been added to any node and then decide which node to add them to.
Bear in mind there will be a delay once you upload your files until they are attached to the node until the next cron job runs.
This is not a good solution and if I could give you any advice it would be not to do it - The reason you upload files through the Drupal interface is so that they are tracked in the files table and can be re-used.
Also the way you're proposing leaves massive amounts of ambiguity as to which file will go where. Consider this:
You have two nodes, one about cars and one about motorcycle sidecars. Your code will have to be extremely complex to make the decision of which node to add to if the file you've uploaded is called 'my-favourite-sidecar.jpg'.

Resources