The coding language is Java.
I have a ByteArray embedded in ActionScriptObject.(http://smartfoxserver.com/'>Smartfox Server)
I want to convert it into ByteArray.
The idea is to save it as an image.
This a sequel to the post --> Convert Byte Array from Action Script to Image in Java and save it
Have tried http://www.javafaq.nu/java-article236.html'>this method
It failed with the
java.io.NotSerializable Exception
Regards,
naveenj
The NotSerializableException is because the ActionScriptObject does not implement Serializable.
The ActionScriptObject does not support byte arrays. This is according to information found on the SmartFox Server forum. This probably means that when it creates the Java object that represents your ActionScript object, it does not copy the "arr" property at all!
To transfer the image data to the server you will have to use a network socket and write the data down the wire.
Reading the docs for Smartfox Server, there is a SocketLoader tutorial in chapter 8.17 which should allow you to transmit the image data to the server. http://www.smartfoxserver.com/docs/index.htm?http://www.smartfoxserver.com/docs/docPages/tutorials_pro/17_socketFileLoader/index.htm
Have you tried with JBoss Serialization? http://www.jboss.org/serialization
Regards.
Related
I want to send the ByteBuffer from FlatBuffers over network to an Android Application.
I tried using echo $builder->sizedByteArray, but then I'm wondering how to deserialize this String.
Note that this bytearray has to be sent in a way suited to binary transmission, not text.
As for deserialization with Java, have you looked here: https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html (make sure you select Java as your language) ? You can use ByteBuffer.wrap with a byte[] you received over the network.
I am using Protocol Buffers for my data and want to store and retrieve this data from Memcached (running on ElastiCache). I am using the MemcachedClient in Java.
I am currently storing data to Memcache using code similiar to this:
memClient.set("keyString", protobufBuilder.build().toByteArray());
But, I am not sure how to get this data from Memcached and convert it back into a Protobuf object.
Any help is really appreciated.
I figured it out.
I simply typecasted the data I get from MemcachedCleint to byte[] and gave it as input to the pasreFrom method of my Protobuf object.
Currently I am sending images between an IOS app and Java web service as Strings - is there a better way to do this and if so what method is it - the Strings to represent images are huge and its quite hard to manage.
Thanks
If the image implementation you're using is serializable, serialize it.
I understood that you are currently using BASE64 encoded images being represented as strings, correct?
This approach is reasonable for small binaries/images and also to avoid many individual calls for each image in case of an list of images for example.
Anyway - a proper way would be to use a POST or PUT request to send an image to a Java web service in form of an x-www-form-urlencoded request. This is similar to what you do in a typical upload form.
Look at the example in this answer:
Send image to server as binary data
For the download of an image you can use a GET NSURLRequest (include required headers, authentication or other information to the request) and convert the received NSData to an image.
[UIImage imageWithData:dataReceivedFromURLRequest];
Or directly create the NSData for simple http requests like this and convert it to an image:
NSData *urlData = [NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://my-web-service/image.png"]];
On the server side you could create an image REST endpoint using JAX-RS for example.
Please note that frameworks like AFNetworking help a lot providing convenient ways sending and receiving image/binary data.
Ok, just a simple question, I would like to send a object via java and obj-c. Is this possible to do so? Or I need to change the object to string or something first, and convert it back in to the receive side? Thanks.
It is possible to send a serialised Java object to objective C over a socket, but recovering it is difficult since you'd need to write a library to parse the binary data stream. It's possible someone has already written such a library.
It's easier to send objects encoded in JSON or XML, or with Google protocol buffers.
I would like to send a object via java and obj-c
This is the classic problem of communication between different systems/languages.
The solution has always been XML (usually SOAP which is not my taste) and nowadays the options #Joni mentions in his answer
An extra requirement is that the attachments can be stored as a stream, as there might be potentially very large binaries that has to be saved. Videos etc.
I have looked at Voldemort and other key value stores, but they all seem to expect byte arrays, which is completely out of the question.
This should, preferrably, be written in Java, and be embeddable.
The use case is:
I have written a HTTP Cache library which has multiple backends.
I have a Memory based one (using hashmap and Byte arrays), Derby database, persistent hashmap with file attachment, EHCache with file attachment.
I was hoping there was something out there which didn't use the file system, or if it does, it's transparent from the API.
I am storing the Headers with some more meta information in a datastore. But I also need to store the payload of the HTTP response.
The HTTP response payload might be VERY big, thats why I need to use streaming.
Why is a byte[] value out of the question? Any object graph can be serialized into a byte array!
Have you looked at sleepycat's Berkeley DB (it's free)?
EDIT - having seen jhedding's comment, it seems like you need to store data which is too big to fit into a single JVM in one go. Have you:
Checked that it won't fot into a 64-bit JVM?
Tried using a network file system? (NAS or whatever)