Hello Gears maintainers,

As we spoke with Michael a while ago, it would be good if Gears supported
storing a persistent reference to a file instead of storing the blob itself.
It will be useful for manipulating very large files which shouldn't go
straight to the cache.

I propose to implement it as separate methods, because this feature -
although similar - is conceptually different from capturing the blob. They
shouldn't operate on Blob objects, but on Files. The new methods of
ResourceStore class would be as following:

void captureExternalFile(File file, string url, string optContentType)
Parameters are analogous to captureBlob().

File getAsExternalFile(string url)
This method would throw an exception if url is from different origin
*or*the resource was captured as a blob, and not as a file.

Please note that I think there's no reason for getAsBlob() not to work in
this case. It should be an universal method. Also note that even if my
particular case would be solved without getAsExternalFile(), it's still nice
to have it to maintain symmetry of the API.

*Rationale*

The alternative would be to use some kind of additional flag in
captureBlob(), like this:

void captureBlob(Blob blob, string url, string optContentType, boolean
optReferenceOnly)

But then, you have to remember that blobs are *not* guaranteed to be backed
as files, and you'll have to enforce it not on API, but on implementation
level. Taking into consideration the fact that it's currently impossible to
check what is the blob's backend, this would be unacceptable. Plus, it's a
bad design IMO.

Using Files to do the job here will leave you enough space to potentially
seamlessly incorporate further metadata about the file (like mtime etc.),
without even touching this API. Right now, you'll get the file name "for
free".

Michael, may I ask you for comments on this?

-- 
Bartosz Leper
Software Engineer

Google Poland sp. z o.o.

ul. Emilii Plater 53, 00-113 Warszawa
Sąd Rejonowy dla m. st. Warszawy w Warszawie,
XII Wydział Gospodarczy Krajowego Rejestru Sądowego, KRS 0000240611.
NIP: 525-23-44-078, Kapitał zakładowy Spółki 400 000, 00 zł.

Reply via email to