Interacting with Attachment type Field

Isskint

Slowly Developing
Local time
Today, 18:43
Joined
Apr 25, 2012
Messages
1,302
Okay, so this thread got my interest.
Image file size is approx vert pxl * horiz pxl * bitdepth. So if you can pull all 3 of those bits of file property you could calculate the file size.
Problem, although vert pxl * horiz pxl are accessible to an inspection of the extended file properties,that is only as a saved file, NOT in the attachment field. BitDepth is NOT accesible to extended file properties.
I started looking at the attachment type field. The range of properties and methods MS have exposed to the developer are - tiny!! So after a little surfing I came across a few bits of code and threads that has enabled me to put something together that will get the 3 bits of information and delete any attachments whose file size does not conform to a supplied criteria.
The biggest acknowledgement has to go to Wayne Phillips at everythingaccess.com. He has a brilliant DB tool that provides the ability to interrogate file properties to a much greater depth. Also BrokenBiker on this forum with this thread. So much of the info i looked at mentioned (and demonstrated) interaction with the attachment object, but they all had errors in the code. The 'hardest' part was getting at the necessary properties, but this is achieved by saving the file to a temp folder.
Now its not pretty :rolleyes: but it does the work; especially for this scenario. The function will step through all files attached to an attachment field, save a temp copy, get the file properties, apply these to supplied criteria and delete.

Copy ALL the modules to a database needing some 'attachment' house cleaning. In the DeleteAttachments module is a sub called InitiateThePurge where you supply the necessary info.

Hopefully some of our more capable and savvy members will be able to clean this up.
 

Attachments

Users who are viewing this thread

Back
Top Bottom