sync assets folder - FilesystemSyncTask gone?

Silverstripe Version: 4.2

I am migrating a wordpress blog into silverstripe and wanted to import some images across into the assets folder. It seems as though the FilesystemSyncTask has been removed. Is there another way to achieve this? That was such a useful feature when you are FTPing files or migrating sites into Silverstripe.

1 Like

Yes, it’s gone. I’ve found this issue when upgrading from SilverStripe 3 to 4 as well. You now have to upload everything through the Asset section of the CMS for it to be a part of the file database.

It has been done because not everyone is using the local filesystem so it would not work if you were using Amazing S3 for asset storage. Although I suspect most people are still using the local file system so I think it should still be an option.

Make sure to set Legacy Filenames to true in the config.yml as well so as not to get every file renamed at least until you’re ready to turn on file versioning (which makes an already messy assets folder even messier).

legacy_filenames: true

SS4 is also storing all _resized images right next to the original file as well so cleaning those up is now a much bigger pain than it used to be in SS3.

That’s not entirely true. You can still add files to the asset system programatically:

$file = Image::create();
$file->setFromLocalFile('/path/to/local/image.jpg', 'Image File');
if (class_exists(Versioned::class)) {
  $file->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
1 Like

That is very nice code but where do you run it from?

Is there a way to make it into a CustomTask?

That’s just a code-snippet obviously. You can run it anywhere you like. You could add it to a dev task, certainly.
When migrating WP sites, I use it in a script which parses an exported XML file from Wordpress and automatically copies the images from the source site into the new SS site.

That script you use to parse Wordpress XML sounds very useful. Would you be willing to share that at all?

1 Like

It could be a good practice, but my ‘Files’ have a lot of associations, like ownerID, parentID etc. How about those items? They will lost as the files are new now. :frowning:

I would recommend creating a new BuildTask which handles your specific scenario.

I’m going to lock this thread for now, since it was started in 2018 and was about a specific scenario of importing files into Silverstripe install.

If you have a specific query about migrating / moving files during an upgrade, please start a new topic with some details of your project.

1 Like