3429 Posts in 1057 Topics by 734 members
|Go to End|
8 December 2012 at 1:12pm
I have a class that downloads images from an external server to my SS site. What is the best way to create an image Object for a has_one relation from this file. Off the top of my head I was going to manully create a new Image from the file name and then after write get its ID and attach it to the other DataObject. But manually craete the Image object in my file table seems redundant. I assume I should just be able to use the built in file system to handle my file write and file object creation, just not sure where to start
8 December 2012 at 4:24pm
I was going to manully create a new Image from the file name and then after write get its ID and attach it to the other DataObject.
You're on the correct track.
But manually craete the Image object in my file table seems redundant.
No you'll need to manually create the Image object as well as the actual file and ensure that the Image object you created has the correct filename to link to the image.
$image = new Image();
$image->Filename = 'assets/foo.jpg';
$image->Title = 'Foo';
$obj->ImageID = $image->ID:
|Go to Top|