Page MenuHomePhabricator

Generalization of the File::getArchiveUrl method
Closed, DeclinedPublic

Description

Author: ed

Description:
In writing an extension to implement a filerepo which uses the Amazon S3 system, I found that there were a few changes needed to the File class. This is because the File class assumes that it knows how to calculate the URL based on the hash directory and so forth. In the case of the S3 system, the URL may need a "signature", which is a suffix to the normal URL of the desired file. This affected the links presented on the ImagePage screen for the archive files.

To make a long story short, I added a couple of lines to the beginning of the File::getArchiveUrl() method:

if(is_callable(array($this->repo,'getArchiveUrl'))) {
   $path = $this->repo->getArchiveUrl($this, $suffix);
   return $path;
}

With this change, the repo, if the corresponding method exists, is used to calculate the URL for the archive files, allowing for signatures, etc.

With just this change, my S3 extension works. But I noticed that there are other methods in the File class which have the same problem, but I am unsure what effect they might have. Also, it is possible that the ImagePage screen creates the file object incorrectly (the "object factory" should be used, and it isn't, so the inheritance doesn't apply).

Anyway, I would like to publish my S3 extension, but I would need to know if this change can be made to the File::getArchiveUrl() method, or if some other change would be better.


Version: 1.15.x
Severity: enhancement

Details

Reference
bz24347

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:06 PM
bzimport set Reference to bz24347.
bzimport added a subscriber: Unknown Object (MLST).

Bryan.TongMinh wrote:

You just should override the File::getArchiveUrl method in your derived File class.

ed wrote:

That is what I tried to do first, but since the "object factory" isn't called, it doesn't use my class. Anyway, further debugging showed that I'm missing a few overrides in my S3 file class, which is why it isn't calling the object factory. I'll check it some more.

Thank you for your help.