How can I read and write Adobe Flash Media Server Remote Shared Object (FSO files) directly without using flash?
Preferably, I would like to use python, php or java, but I don't mind using a different coding language. I am looking for the file structure, so I could read and write the files just like this app that reads and writes to sol
files.
The reason I need this is to be able to fix files that has been created on one machine so they will have the right setting for a new machine i'm setting up.
Thanks!
EDIT
I can read some of the file content using notepad, but some of the characters aren't showing right, for example, check this out http://pastebin.com/AWdJ2ZcR
Attached output from the hex editor:
I've tried using the pyamf
with no luck:
from pyamf import sol
lso = sol.load(file)
I got the following error:
raise pyamf.DecodeError('Unknown SOL version in header')
pyamf.DecodeError: Unknown SOL version in header
These files use AMF format, which is actually fairly simple to read and write. Python has pyamf library. Java has a bunch, something like 3 or 4, but two most commonly used are part of the Granite Data Services and one previously developed by Adobe - Blaze Data Services. PHP also has several implementations, AMFPHP was historically the first, then it was forked and the main development branch merged into Zend Framework, but the AMFPHP project itself still exists and is being worked on, but rather slowly.
There are however certain things you must know:
AMF isn't necessarily self-defining. This means that there is an option in it for sending arbitrary payload, actually, several such options, not really related.
There is a tag type which describes the following payload as being "custom", i.e. it only records the length of bytes to read, which the reader may or may not understand. This corresponds to implementing IExternalizable
in AS3.
There is an option to omit a field from serialization, in which case instances of the object created in Flash will differ from instances you would parse from the file. This corresponds to the use of [Transient]
metadata.
Anyone can choose to use AMF as a wrapper, while doing actual serialization in a different format and only utilizing the tag corresponding to ByteArray
type. In which case it will be of a little use to you.
AMF 3.0 has "extensions", interestingly, not all users of the format knowingly use them and sometimes discover those by chance. The implementation in the player has special tag types for at least Vector
and Dictionary
classes, but these aren't part of the format specification - most readers don't understand these tags when encounter them.
Certain classes, which are not part of the specification have been historically kept around the reader implementations due to the common use of them in the Flex framework. These would be ArrayCollection
, RemoteMessage
and few others. ArrayCollection
is especially important because it is basically the same as Array
, but it is sent with "custom" serialization tag.
It is also important to understand the nature and behavior of ECMAScript arrays - they might be a source of server faults when decoded. ECMAScript arrays are sparse, which means they don't necessarily contain all indices between 0 and the greatest index, they are a mix of an array (the first continuous block of indices starting at 0) and the rest is encoded as a hash table with integer keys. Thus you can potentially serialize an array of the length of 2^31, but fail to allocate this much memory on the server side when interpreting this array as an actual array.