I develop an LDAP interface program which can modify person attributes, but when I try to modify the value of the photo attribute with an url string, I have this exception :
org.springframework.ldap.InvalidAttributeValueException: [LDAP: error code 21 - photo: no validator for syntax 1.3.6.1.4.1.1466.115.121.1.23];
I think I must send a JPG photo file to ldap but I don't know how to do it...
Anyone has an idea?
First, when you encounter such an error with a syntax OID, you can submit it to the OID repository. Here it will give you the following information "Values in this syntax are encoded as if they were octet strings".
This means that you have to encode your JPG or PNG file in Base64 and set the attribute with this value (in fact an array).
Second, in my understanding, there are 3 attributes to store photo-Data jpegPhoto, Photo and thumbnailPhoto. But for me it's better to store photos on a file system or a database and put in the Directory ans URL or something like that.
You'll find here a tutorial to handle them with java.
Related
I need to upload an image from android app to a java server. I tried to define the type image like a string and to convert the image, that the user can upload from documents or take with camera, into a base64 string. But when i convert this image in base64 and put this inside a string to save it in database, server give me a 500 internal sever error and this error message:
"com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'image' at row 1"
The Db is in Mysql and i use this from java server.
So, how can I save a base64 image to my server? Can I use a different type?
Thank you!
you can use volley library. for more details these links are useful
first_link and second_link
In our platform, we use a certain format from paths. In the Android App, it receives those paths to load some data or do something.
I want to do all the data handling using content provider, I want to give the path and get data. A simple transaction.
When I read into content providers, the documentation and all the tutorials out there always use "content://" at the beginning. However, I want to use our own start of the path which is usually "is-://". Can something like this work?
no, this is how the system categorize the uri as content provider.
its like relacing file:// with something else.
After referring to Developer.google site
A content URI is a URI that identifies data in a provider. Content URIs include the symbolic name of the entire provider (its authority) and a name that points to a table (a path). When you call a client method to access a table in a provider, the content URI for the table is one of the arguments.
From this I believe you can't set it on your own as it includes the symbol name.
Also why do you want to change it?
I have a JSON that looks more or less like this:
{"id":"id","date":"date","csvdata":"csvdata".....}
where csvdata property is a big amount of data in JSON format too.
I was trying to POST this JSON using AJAX in Play! Framework 1.4.x so I sended just like that, but when I receive the data in the server side, the csvdata looks like [object Object] and stores it in my db.
My first thought to solve this was to send the csvdata json in string format to store it like a longtext, but when I try to do this, my request fails with the following error:
413 (Request Entity Too Large)
And Play's console show me this message:
Number of request parameters 3623 is higher than maximum of 1000, aborting. Can be configured using 'http.maxParams'
I also tried to add http.maxParams=5000 in application.conf but the only result is that Play's console says nothing and in my database this field is stored as null.
Can anyone help me, or maybe suggest another solution to my problem?
Thanks you so much in advance.
Is it possible that you sent "csvdata" as an array, not a string? Each element in the array would be a separate parameter. I have sent 100KB strings using AJAX and not run into the http.maxParams limit. You can check the contents of the request body using your browser's developer tools.
If your csvdata originates as a file on the client's machine, then the easiest way to send it is as a File. Your controller action would look like:
public static void upload(String id, Date date, File csv) {
...
}
When Play! binds a parameter to the File type, it writes the contents of the parameter to a temporary file which you can read in. (This avoids running out of memory if a large file is uploaded.) The File parameter type was designed for a normal form submit, but I have used it in AJAX when the browser supported some HTML5 features (File API and Form Data).
First, this is my first time building both of webservice and android client at the same time, so please kindly help me. My goal is to be able to upload a file from android apps and download it from the webservice.
This is what i did for upload (working, but im not sure this is a best way) :
Convert the image to base64 String in android apps
Send that converted string (form image) to the webservice.
Decode that string with base64_decode function in the webservice.
Save the image from the decoded string, using file_put_contents.
Input the decoded string to the BLOB field in my database.
What make me confuse is, if i already saved the image file (step 4), do i still need to save it to the BLOB column (step 5)?
Now, i got confuse with the download part. This is what im planning to do :
Get the image file from step 4 in upload using file_get_contents (return string)
Send the result (string) to my android apps
Get the string and convert it to the image (how?)
Is it all i need to download?
Do i need to use base64_decode or base64_encode in download? When do i use it?
Sorry if my question sounds silly, i still dont get the logic.
Thanks a lot for your time, all help is appreciated.
What make me confuse is, if i already saved the image file (step 4), do i still need to save it to the BLOB column (step 5)?
No you don't. You can store in DB just a reference to that file, like filename or full path.
Now, i got confuse with the download part. This is what im planning to do :
Get the image file from step 4 in upload using file_get_contents (return string)
and base64_encode it
Get the string and convert it to the image (how?)
You need to base64 decode it, because you encode it before sending it from the server. (step 1)
I'm currently writing some MATLAB code to interact with my company's internal reports database. So far I can access the HTML abstract page using code which looks like this:
import com.mathworks.mde.desk.*;
wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser;
wb.setCurrentLocation(ReportURL(8:end));
pause(1);
s={};
while isempty(s)
s=char(wb.getHtmlText);
pause(.1);
end
desk=MLDesktop.getInstance;
desk.removeClient(wb);
I can extract out various bits of information from the HTML text which ends up in the variable s, however the PDF of the report is accessed via what I believe is a JavaScript command (onClick="gotoFulltext('','[Report Number]')").
Any ideas as to how I execute this JavaScript command and get the contents of the PDF file into a MATLAB variable?
(MATLAB sits on top of Java, so I believe a Java solution would work...)
I think you should take a look at the JavaScript that is being called and see what the final request to the webserver looks like.
You can do this quite easily in Firefox using the FireBug plugin.
https://addons.mozilla.org/en-US/firefox/addon/1843
Once you have found the real server request then you can just request this URL or post to this URL instead of trying to run the JavaScript.
Once you have gotten the correct URL (a la the answer from pjp), your next problem is to "get the contents of the PDF file into a MATLAB variable". Whether or not this is possible may depend on what you mean by "contents"...
If you want to get the raw data in the PDF file, I don't think there is a way currently to do this in MATLAB. The URLREAD function was the first thing I thought of to read content from a URL into a string, but it has this note in the documentation:
s = urlread('url') reads the content
at a URL into the string s. If the
server returns binary data, s will
be unreadable.
Indeed, if you try to read a PDF as in the following example, s contains some text intermingled with mostly garbage:
s = urlread('http://samplepdf.com/sample.pdf');
If you want to get the text from the PDF file, you have some options. First, you can use URLWRITE to save the contents of the URL to a file:
urlwrite('http://samplepdf.com/sample.pdf','temp.pdf');
Then you should be able to use one of two submissions on The MathWorks File Exchange to extract the text from the PDF:
Extract text from a PDF document by Dimitri Shvorob
PDF Reader by Tom Gaudette
If you simply want to view the PDF, you can just open it in Adobe Acrobat with the OPEN function:
open('temp.pdf');
wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser;
wb.executeScript('javascript:alert(''Some code from a link'')');
desk=com.mathworks.mde.desk.MLDesktop.getInstance;
desk.removeClient(wb);