Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2019-10-08 10:25:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,760
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

What about if we timestamped the upload process the moment it began? Or assigned it a UUID of some description (even an md5). In effect, giving it a unique key based on the time the Upload button was hit. If that’s sent along with each file, that ties them to a ‘group’ or batch and they could then be differentiated server side from any other upload that may occur concurrently.

Combined with the sequence number and the total, would that work?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#22 2019-10-08 11:51:09

etc
Developer
Registered: 2010-11-11
Posts: 3,296
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

Bloke wrote #319590:

And I suppose different users could be doing it at the same time too huh. So unless we somehow knew which user the upload belonged to, we’re sunk.

This we actually know, because the user admin cookie is sent on every connexion, be it xhr or not. But there still is a risk of confusing two uploads from the same user. Images are not really concerned, but since we can upload tons of Gb now, a user could forget about an upload he has started an hour ago.

What about if we timestamped the upload process the moment it began? Or assigned it a UUID of some description (even an md5). In effect, giving it a unique key based on the time the Upload button was hit. If that’s sent along with each file, that ties them to a ‘group’ or batch and they could then be differentiated server side from any other upload that may occur concurrently.

Combined with the sequence number and the total, would that work?

That’s what I meant by unique id (timestamp, hash, etc). I think the best way is to let plugin authors add it via some UI callback, either as hidden input (the script sends them all along with each file) or via JS. The question is: how would you treat it server-side? Every file triggers a separate request to ?event=file, so your plugin will be called anew for every file. It must then store somewhere (db?) the batch upload information (e.g. what is already uploaded) until all files are uploaded. That’s certainly feasible, but I don’t know whether we should store these batch upload ids in core or leave it with plugin authors.

Offline

#23 2019-10-08 12:07:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,760
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

etc wrote #319591:

I think the best way is to let plugin authors add it via some UI callback, either as hidden input (the script sends them all along with each file) or via JS.

That works for me. pluggable_ui()?

Every file triggers a separate request to ?event=file, so your plugin will be called anew for every file.

Yeah, that is a pickle. I was thinking originally of storing it in a global, but that won’t help as it’ll be trashed after each file is done uploading. So the only persistent storage we have is the database or filesystem. The plugin’s data column is an option, since it can be used as a scratchpad, but it could get messy updating it when each file is uploaded. And old data wouldn’t be able to be purged easily.

If we’re allowing plugin authors to set the batch ID, it should probably rest with those authors to handle them. If Txp was generating the unique IDs as part of the upload process, then it’s up to core to store them for the life of the upload and to present such info to any interested parties during callback. Since we can’t predict what people might use them for, I’d be tempted to just permit the mechanism and leave implementation to plugins.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#24 2019-10-08 12:54:49

etc
Developer
Registered: 2010-11-11
Posts: 3,296
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

Bloke wrote #319592:

The plugin’s data column is an option, since it can be used as a scratchpad, but it could get messy updating it when each file is uploaded. And old data wouldn’t be able to be purged easily.

That’s actually an option, JSON decoding/encoding is not that hard. Or may be even MySQL XML functions could do.

Since we can’t predict what people might use them for, I’d be tempted to just permit the mechanism and leave implementation to plugins.

I agree, we’d just provide an order/total value.

Offline

#25 2019-10-08 20:58:30

etc
Developer
Registered: 2010-11-11
Posts: 3,296
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

Now fileInputOrder contains order/total combo that you can split. And there is already pluggable_ui callback, though our upload_form() is a mess.

Offline

#26 2019-10-08 23:14:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,760
Website

Re: smd_meta_image: create image/article metadata via IPTC on upload

etc wrote #319598:

Now fileInputOrder contains order/total combo that you can split.

Sweet. I’ll give it a whirl, thank you.

there is already pluggable_ui callback, though our upload_form() is a mess.

Leave it with me. Next on the hit list for the UI library.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB