Upload image to mysql server - java

Is there a way to upload image to my mysql database (Blob type) and make it for example like facebook, when i take a picture it appears a button in front of image so when i click it sends. All the tutorials that i found are like this: https://trinitytuts.com/capture-image-upload-server-android/
And i didnt want to take picture put it in a image view and then send i wanted to do it like i said. Is it possible to do? how can i do it?

Yes! it is possible to save images in BLOB type, but it increases your database size. Hence I will suggest you to upload images to server and just save their path/URL in a database. You can retrieve images using that URL.
Saving images as a BLOB is not a good idea for large images.

yes it is possible.
usign post
usign post multipart
remember the backend for test.

Related

Downloading images from url and saving them on disk with Picasso

My app is downloading images with Picasso like this:
Picasso.with(getBaseContext()).load("https://www.sestavsisvujsvet.cz/files/magnetky/"+id+".png").placeholder(R.drawable.magnetka_placeholder).error(R.drawable.magnetka_placeholder).into(obrazek);
and it works well, but I need to save images to disk, because Picasso's caching mechanism isn't enough (I have up to 870 images which will be frequently seen by the user).
Is there any way to download the image, store it and load it from disk later?
I tried to find some solution to this, but I wasn't able to find anything useful.
Maybe it would be better to download them without Picasso, but I am not sure if it's possible.
I don't mind replacing Picasso completely and using another library, as long as it's capable of saving the images.
Thanks!
Please have a look at this for downloading image.
There are some changes in getting android storage for that please have a look here
After downloading images you need to manage them locally, use sqlite for keeping track of your files.
Basically you need to download images, and after success, save entry in Database which will include fields like location, file_name, create_on, etc. Now you can get images from database
Hope this will help!

Java - Live Streaming Video which uploaded to Database

I think the title says all, but here's what I've done so far:
I managed to upload video to MySQL with Large Blob
Currently, I also managed to stream the video, but this way take 2 steps, which is:
First: I extract the blob into local directory
Second: I use that directory path as src in my video playing page.
Now that my lecturer wants it without extracting to local disk first, he wants to live streaming from database. I only managed to do this if it's a picture, but a video I don't get any clue.
I hope anybody could help me or at least give me clues, thanks in advance :)
I think this should be a good place to start from:
this
Also, if you are just downloading the file, this link might help.
And if you have your own software on the clients side to show the stream, I would suggest that you will open a socket between the client and server and then just sent the video in pieces.

Generate image and display it inside JSP along with other content

I'm using JFreeChart to generate a dynamic chart depending on the user input. I have a JSP with some textbox and combobox, the user makes the input and submits it, and the Action process it, generating an image of a chart. I need to display this image on the same JSP as before, below the textbox/combobox.
If I use response.setContentType("image/jpeg"); etc... then I get a page with the image alone. I thought of saving the image to a file and then access it with <img >, but I'm not sure that will work (need to save it to WebContent and I may not be able to access it always?).
Is there a way to somehow cache the image and then access it inside the JSP through an <img> or something? Maybe JFreeChart has an easy way to do what I want?
If it matters, I'm also using struts and spring on my webapp.
Thanks in advance.
I've not tried it, but you might look into org.jfree.chart.imagemap and a suitable URL generator from org.jfree.chart.urls. An outline of implementing a PieURLGenerator is illustrated here.
Well, if you generate the image on the server side, you could always just store it in a temp directory using something like a UUID to generate a unique name for it, and concatenating the image file extension on the end of it.
Make sure that the directory the image is generated is accessible on the webserver, and then send the URL path to the image file on the server back to the JSP using ajax (Direct Web Remoting), for display using Javascript.
Just make sure you also have a chron job or service to clear the older files out of the directory now and again.
You should have a servlet that can create the image you want solely from the URL. The URL can then contain an id, which maps back to an object in your program containing raw data in memory. The servlet then generates the image and returns it.
You can then simply set the url of the image in your current web page in Javascript, and it should be loaded.
This is because JSP's are character oriented which do not lend well to binary data so you need to have a servlet do it.

access website within android code and retrieve a generated image

This description was very hard to word. Basically I want to know if it is possible to access a website inside Android coding without actually sending the user to that website.
What I want to do is use a free website that generates a random pic after you upload your picture to it. I want the user to be able to upload their selected image to the website, and I guess somehow in code make that website generate an edited image and retrieve it back into the application for further use.
I know this sounds really ridiculous but I just wanted to know if this was at all possible before I try writing the code. Thanks!
The first thing you need to do is do an HTTP post upload of your image, as outlined here:
Upload image
Then you can do your processing on the server side - you didn't specify which platform you are planning to use on the server side, but in PHP you might want to look at this:
HTTP POST file upload
Finally, you'll want to retrieve the resultant image you made available on the server side this way:
Retrieve image from an URL

Save image in Oracle without retrieving a BMP later

Right now I'm facing some performance issues in a web app because of a situation with Oracle saving images and my webapp getting them.
The database where the image is stored gets it from a Oracle Forms' form, which allows user to save some data along the image (as a BLOB). No matter the format you choose as input, it gets saved in a table with its description and stuff, with the corresponding field getting the image is a BLOB.
Now going to the webapp, it reaches the table through a web service querying a stored procedure and a Java WS client, so my webapp gets the image and saves it in the webapp's server's temp folder while needed. The output does not get any particular extension because the DB doesn't tell which extension should it be. Anyhow, the broswer can tell using the metadata. A brief schema of the process goes as follows
Presentation layer <--- Business logic <--- WS Client ---o)--- WS <--- Stored Proc <--- BLOB column
My problem is: how can I avoid the DB serving a bitmap? The performance is awful in specific situations and poor connections because of loading a 1.5MB bitmap. And this webapp must be able to work properly in 256Mb connections. What can be done, then?
Thanks for your help.
Edit: The thing can be treated using BFILE datatype. Thanks for your help. (2010/10/20)
Edit2: The images are uploaded to the database thru a client/server system build in oracle forms (6i/10g). The form itself is the one who stores the image as a blob in the table, transforming it into a bitmap, doesn´t matter if the uploaded image is a light jpg (2011/12/07)
Not sure at which layer you actually want to handle things.
If it is the database layer, then I suspect you need to start using ORDSYS.OrdImage datatypes, and you can them make use of the built-in format conversion operations to turn BMP to JPG or whatever.
Also consider is the problem with large bitmaps or with large image files in general.

Categories