zberentey/liferay-portal — pull request #181 by peterborkuti (2012-11-30 08:56:14+00:00)
Title: LPS-31081 S3Store must add slash at the beginning of a file name because of coherent behaviour

I checked FileSystemStore store, and it creates file-names with a SLASH in the beginning, so all the classes which extends BaseStore must implement getFileNames in a way like this: SLASH directory name SLASH filename.

And all the classes which uses BaseStore extenders, must add the files with a directory-name starts with SLASH in addFile.

Because of this seems to me a rule, but we did not say it loud, I implement an "if" in the getKey method of S3Store. So, if a class calls "addFile" without a starting SLASH, it will be working.

If a fileName starts with slash or without slash, the "if" structure will be ok.
If a filaName contains slashes, there wont be any problem.
If a fileName ends with a slash, it will be a problem, but I could not create a file which name ends with a slash.

I checked some of the BaseStore's extenders, and DBStore did not get the fileName with a slash in the beginning, and it caused an
error with Wiki. (wiki uses addFile method without beginning slash).

I think, that there is a problem in S3Store:
we use the same character for file-separator as for key-separator (slash). I tried S3Store with ":" as the key-separator, and it worked.

Now we store files on Amazon like this:
10154/0/wiki/10439/dog-picture-photo-newborn-puppies.jpg/1.0

But probably it will be better like this:
10154:0:/wiki/10439/dog-picture-photo-newborn-puppies.jpg:1.0
(the ":" is just for example, it could be other character also)