[IMPLEMENTED] Bulk updating of images

Hi Sebastian,

I have about 400 existing images that I need to update. The updated files have exactly the same names as the ones already on Squidex. I know that I can drag/drop the files on-by-one to update them, but is there any way to do them all at once?

I suppose that if I delete the existing images all references to them (in schema records) will be removed, so that’s not a good approach.

Thanks for your help.

-Barton

You have to write your own tool using the API to implement that. Perhaps I can provide a sample next week or add a feature to the CLI.

Thanks, Sebastian. It would be wonderful if you could provide a sample or enhance the CLI. I’m sure that other users would also benefit from this functionality.

-Barton

1 Like

I have updated the existing CLI command to also make updates: https://github.com/Squidex/squidex-samples/blob/master/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs#L39

This command allows you to upload a full folder hierarchy to Squidex.

This sounds great Sebastian! Thanks! I’ll try it out soon.

-Barton

1 Like

Have you had a chance to test it?

Hi Sebastian. I just tried it, but got an error. Here’s the command I used:

.\cli\sq.exe assets import .\test_som1_images -t images

The folder, “.\test_som1_images” is a folder on my local drive with the images I want to update.

The images are in an “images” folder on Squidex, which is why I used the, “-t images” parameter.

The error I received is:

ERROR: HTTP Response:

{"traceId":"00-fc6a361d787f0745ea735ae11d07cce4-c252bc42ec53b9e3-01","type":"https://tools.ietf.org/html/rfc7231#section-6.5.4","statusCode":404}

Squidex.ClientLibrary.Management.SquidexManagementException: App not found.

Status: 404
Response:
{"traceId":"00-fc6a361d787f0745ea735ae11d07cce4-c252bc42ec53b9e3-01","type":"https://tools.ietf.org/html/rfc7231#section-6.5.4","statusCode":404}
   at Squidex.ClientLibrary.Management.AssetsClient.GetAssetFoldersAsync(String app, String parentId, Nullable`1 scope, CancellationToken cancellationToken)
   at Squidex.CLI.Commands.Implementation.Sync.Assets.FolderTree.QueryAsync(String id, Boolean needsChildren)
   at Squidex.CLI.Commands.Implementation.Sync.Assets.FolderTree.GetIdAsync(String path)
   at Squidex.CLI.Commands.App.Assets.List(ImportArguments arguments)
   at CommandDotNet.Execution.InvocationResultExtensions.GetResultCodeAsync(Object value)
   at CommandDotNet.AppRunner.HandleException(Exception ex, IConsole console, CommandContext commandContext)
   at CommandDotNet.AppRunner.Run(String[] args)
   at Squidex.CLI.Program.Main(String[] args)

Perhaps I’m using the command incorrectly. (I did select my app configuration before executing it.)

Let me know if I should create an issue in Github.

Do you have an client with proper permissions? And have you set the url properly when registering the app in the CLI?

There was a problem with my config. Once fixed the import command worked perfectly!

Thank you for your amazing responsiveness!

-Barton

1 Like

I don’t know if you have realized it, but it will also keep your folder structure.

That’s good to know.

I’m not exaggerating when I say that Squidex is the most elegantly designed platform that I’ve used in my 45+ years of working with technology. I recommend it whenever I get the chance!

1 Like

Hi Sebastian. One other note on this. In further testing I accidentally included an image file that did not already exist in the app. When the file was encountered the following error was triggered:

Uploading: numbers-1.png
Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Squidex.CLI.Commands.App.Assets.List(ImportArguments arguments)

ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
   at Squidex.CLI.Commands.Implementation.LogExtensions.HandleException(Exception ex, Action`1 error)
   at Squidex.CLI.Commands.App.Assets.List(ImportArguments arguments)
   at CommandDotNet.Execution.InvocationResultExtensions.GetResultCodeAsync(Object value)
   at CommandDotNet.AppRunner.HandleException(Exception ex, IConsole console, CommandContext commandContext)
   at CommandDotNet.AppRunner.Run(String[] args)
   at Squidex.CLI.Program.Main(String[] args) 

Perhaps you want to add a flag to allow import when the image does not already exist? Or make that the default action?

This is a bug, I will have a look.

I cannot reproduce it.

Have you tried it with the “-t” option? That’s how I used the command, in order to target a specific asset folder.

No, I will have a look.

I can still not reproduce it. Perhaps I have just fixed it. You can also send me your folder and exact command if you want.

I installed the latest CLI (v7.16.0) and now it works! Thanks very much!

1 Like