Hi, I've been trying to get jpegs loaded from datastore but keep getting errors with SugarDataStore>>getFilname:id. I use this code:
store := SugarDataStore new. list := (store find:{'mime_type'->#('application/x-squeak-project' 'image/jpeg')} with:#('uid')). id := ((list at:1) at:'uid') asString. store getFilename: id.
I can test different entries in the journal changing 'list at:1' to different numbers. Problem is that the Squeak projects return a file path but jpegs return only ''
Does anybody have a suggestion ?
Karl
On 30.12.2008, at 00:44, karl ramberg wrote:
Hi, I've been trying to get jpegs loaded from datastore but keep getting errors with SugarDataStore>>getFilname:id. I use this code:
store := SugarDataStore new. list := (store find:{'mime_type'->#('application/x-squeak-project' 'image/jpeg')} with:#('uid')). id := ((list at:1) at:'uid') asString. store getFilename: id.
I can test different entries in the journal changing 'list at:1' to different numbers. Problem is that the Squeak projects return a file path but jpegs return only ''
Does anybody have a suggestion ?
It's a simple typo I assume - list is an array of 2 elements, the second is the total number of items, the first is an array of dictionaries for each entry. Your code should look like
list := (store find: ... with: ...) first.
With that change it works fine here (and the #asString send is not even needed).
If it does not then maybe your jpeg journal entries indeed do not have files in them? Can you open them in another activity?
- Bert -
Bogus jpeg entries was indeed the problem. Thanks.
I had some problems with SugarDatastoreDirectory>>entries by the way. Shouldn't it be at:'title' asString only without the changing of back slash to forward slash ?
Karl
On 12/30/08, Bert Freudenberg bert@freudenbergs.de wrote:
On 30.12.2008, at 00:44, karl ramberg wrote:
Hi, I've been trying to get jpegs loaded from datastore but keep getting errors with SugarDataStore>>getFilname:id. I use this code:
store := SugarDataStore new. list := (store find:{'mime_type'->#('application/x-squeak-project' 'image/jpeg')} with:#('uid')). id := ((list at:1) at:'uid') asString. store getFilename: id.
I can test different entries in the journal changing 'list at:1' to different numbers. Problem is that the Squeak projects return a file path but jpegs return only ''
Does anybody have a suggestion ?
It's a simple typo I assume - list is an array of 2 elements, the second is the total number of items, the first is an array of dictionaries for each entry. Your code should look like
list := (store find: ... with: ...) first.
With that change it works fine here (and the #asString send is not even needed).
If it does not then maybe your jpeg journal entries indeed do not have files in them? Can you open them in another activity?
- Bert -
On 30.12.2008, at 12:50, karl ramberg wrote:
I had some problems with SugarDatastoreDirectory>>entries by the way. Shouldn't it be at:'title' asString only without the changing of back slash to forward slash ?
This actually changes any forward slashes to back slashes. Otherwise splitting a full path name into its directory and file components would get confused. This is done purely so the file names are not only the hexadecimal uid, but show some of the entry title, too. When retrieving the file contents later, the uid is extracted from that embellished file name.
It's an awful hack, but too much code assumes all files are identified simply by a string path name with directory separator chars. To properly integrate the Journal we might have to separate the actual file locator (url, datastore id, or whatever) from its human-readable title in all the tools that show files.
- Bert -
etoys-dev@lists.squeakfoundation.org