I have a plugin and I want it to move some files into a system asset source.
I have a dropdown to select the folder which gets its options like this and shows a dropdown to select a folder Id.
public function getSettingsHtml()
{
$sourceIds = craft()->assetSources->getAllSourceIds();
$tree = craft()->assets->getFolderTreeBySourceIds($sourceIds);
return craft()->templates->render('backups/_settings', array(
'settings' => $this->getSettings(),
'tree' => $tree
));
}
so in my controller what i want to do is copy a file into that folder? I have the full path to the file but not sure where to go from there? Ideally it wouldn't matter if it were local storage or cloud storage it would just move it but I'm a little dumbfounded?
Any thoughts?
UPDATE: So I found this method in the Assets Service insertFileByLocalPath()
which seems exactly what i needed
$response = craft()->assets->insertFileByLocalPath($backupsPath, $fileName, $folderId);
which starts to work but i keep getting S3::putObject(): [RequestTimeout] Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
??