Reading the location from where the image is uploaded - spring-mvc

I want to know if this is even possible. One of my requirement is to allow users to upload images, generate new names for those images and rename the images with the new names in the folder from which they were uploaded.
I implemented the first part i.e uploading images based on this blog http://www.raistudies.com/spring/spring-mvc/file-upload-spring-mvc-annotation/
It works fine. But I am unable to find a way to read the location from where these images are uploaded. Usually users will map network drives on their local system and upload these images from those network drives. So I want to if its even possible to read the location.
Any input will be greatly appreciated.
Update: I tried using jquery to read the value in the input filed, but this just give me the image name and not the complete path. eg., C:/Images/OnLoc/abc.img gives me jsut abc.img but I want the complete path i.e C:/Images/OnLoc/abc.img
Thanks,
Lakshmi

It depends. If you are using CommonsMultipartFile, then the getOriginalFilename method might return path data in addition to the filename. As per the API docs:
This may contain path information depending on the browser used, but it typically will not with any other than Opera.
So the short answer is probably not.

You can use JavaScript to store the location in an hidden field when user selects a file to upload and then when user will submit the form, get the value from form bean.

Related

Should I save the download url or the path of images in my database?

After user uploads an image, should I at this point call getDownloadUrl() and store that url https://firebasestorage.googleapis.com/v0/b/myapp.appspot.com/o/myimage.jpg?alt=media&token=mytoken in my database, or should I just save the path /dir/file.jpg and call it later when it's time to display the image?
I would assume it's better to just store the url because there will be more reads than writes, so I can just show the image without another fetch for each of them. What is better practice?
It's better to store both. You'll want to url in order to easily load the image later, and you'll want the path in case you want to delete the record in the database, and also delete the file in storage using the Admin SDK.

google-cloud-vision for internal photo repository

Is it possible to use the google-cloud-vision API to match photos with an internal photo directory or sharepoint? The purpose is to find the best match between a specific photo and the existing photos in the repository.
Programmatically speaking, I don't see why not. The API, depending on how you want to use it, has certain requirements. For example, this API post request needs a image in String format. As long as you write a piece of code to pull and convert your image into String format (base64), it works. You can pull the image from the internet or from Google Cloud Storage or your own local machine (as the example mentioned). The API doesn't know nor care about the original location of the image.

Firebase: Search in storage using comodin

I'm having a problem trying to search images in my storage instance because I have the following structure:
/cityx/cars/{userId}/{numberPlate}/image_1
/cityx/cars/{userId}/{numberPlate}/image_2
/cityx/cars/{userId}/{numberPlate}/image_3
Each user have it's own folder {userId} and within that folder, has registered many cars indexed by the {numberPlate} and finally inside that {numberPlate} folder exists pictures related to the user so I'm performing a search by the numberPlate but the issue I have is related to.. how to search it having the parent folder with a dynamically name (the userId).
Do you know how to perform a search like that?
Kind regards!
The Firebase Storage API doesn't have the ability to search for images. You must know the full path already to find/load an image.
So if you want to be able to search for specific images, you should store the metadata about the images elsewhere. One common place for structured metadata would be the Firebase Database, such as covered here: How to get an array with all pictures?
If you want more wildcard-like search, you'll want to look into integrating an external search engine, such as Elastic Search.

how to modify stored dcm files

I have the need to mopdify the information of patient,study,series,instance,and I have done this by putting information to dataset that stored in database.Now my question is that the information stored in database does has been modified but the dcm files stored in pacs can't modified.Is there any way to modify the dcm files at the same time?
I could be wrong, but I do not believe dcm4chee changes the images when you edit the fields through the web interface. Instead what it does is it modifies the fields in the data base. When an image is retrieved from the dcm4chee pacs, it will prepare and send the modified images. At that point in time it creates a new image header (updated with changes made through the web UI and the changes required because dcm4chee handled the images). The retriever will then get the modified set of images, dcm4chee will continue to store the original images.
To get the modified images issue a C-STORE request and have dcm4chee send the images to another client or pacs. That system will receive the modified images.
If you have DCM4CHEE 2.17.x, then you should be able to edit some information. Go onto the web interface for your installation and look for the Edit [Patient/Study/Series/Instance] Attributes icon (looks like a document with a pencil). If you click on that, you should be able to enter new values for some of the items.
Most PACS will ignore a storage request if they already have the identical SOP Instance UID value. So, another method to change the data is to use a toolkit to modify the fields you want, and then generate new UID values for the images (and it's a good idea to do the same for the study and series UID values too). This will create duplicate entries, but with different values.

Uploading multiple/large files

I have this page where a user can upload documents (multiple documents, size limit 10MB each). It is a two step process. Step 1 has the input form. Step 2 is the preview page with a submit button.
How should I handle the scenario where the user closes the browser while on the preview page, without submitting the form? Should I save the files in a temp location after step 1? Is this a decent solution?
And what are the best practices in general for uploading (reasonably) large files?
Thanks.
Take a look at this:
http://www.codeproject.com/Articles/68374/Upload-Multiple-Files-in-ASP-NET-using-jQuery
One way or another, you'll probably end up looking at a jQuery/AJAX control to do this.
You can use a temporary folder to save the files and copy the files to their final location only on submission of the form.
In any case, it would be better to implement a garbage collector. The garbage collector can empty the temporary folder every night. But when using a garbage collector, if you have a way to identify files that were not submitted (for example, if a row is added to a database upon submission), you can put the files in their final location from the beginning, and let the garbage collector remove them every night.
Upload of large files can be done using a JQuery UI plugin such as Uploadify: http://www.uploadify.com/.
You should pay attention that it uses flash, which on the one hand is very good for uploading large files, but on the other hand it will prevent your application from supporting Apple machines such as iPad.
If the user leaves, then let them start over. More than likely they left for a good reason. If there was a crash, leave the responsibility on their end. If you choose to store their data without them submitting this could allow malicious users to exploit your storage.
You can also look into a process called chunking.
For a more in depth discussion on file uploads in mvc3, see this SO post: MVC 3 file upload and model binding

Resources