Download attachments from Bugzilla

Author Message
User 07/27/2015 12:24 pm
Hello,

I want to download attachments from Bugzilla bugs management system. An example looks like this:
http://bugzilla.sudo.ws/attachment.cgi?id=255
http://bugzilla.sudo.ws/attachment.cgi?id=256 , etc.

As the result of each such request, files with various extensions and names can be downloaded, such as xxx.zip, yyy.jpg, zzz.doc , etc. Also, several files with the same file name (but different content) may correspond with different ids.

I want to automatically create file names for such files by using IDs as prefixes, for example:
255_xxx.zip
256_zzz.doc
...
276_zzz.doc (differs from 256_zzz.doc above).

Can I do it with Substutions functionality? When I trying to use a rule such as:
Apply to: filename
URL: http://bugzilla.sudo.ws/attachment.cgi?
Replace: attachment.cgi?id=*
With: *

then two sets of files are created: attachment files with original (unmodified) names, and html files with names 255,256 etc.



Oleg Chernavin 07/27/2015 07:12 pm
The best way to do this is to add the following line to the Project's URLs field:

Additional=SkipDisposition

Download the Project and then export it to add proper extensions to these files.

Best regards,
Oleg Chernavin
MP Staff
User 07/28/2015 01:30 am
Using Additional=SkipDisposition option will create files like
attachment.cgi@id=255
attachment.cgi@id=256 etc.
with real types of attached files (for example .zip, .doc).

With substituions, it will create different file names according to substitution rules, such as:
255
256 etc.
again with real file types.

But I don't see how an export procedure can rename these files to required format such as:

255_xxxxxx.zip
256_yyy.doc
257_zzzz.jpg, etc.

I cannot see such option in Export window.
User 07/28/2015 02:07 am
I can see the following possible approach to make it work:

1. Without Additional=SkipDisposition option and with Substitution rule like replacing with *.html, two sets of files will be created: attached files with xxx.zip, yyyy.doc names, and html files with attachment numbers, such as 255.html, 256.html etc.

2. Now, a second pass will be required, which would rename attached file by adding a prefix of html file name, and also rewrite a link to attached file inside html file.

By the way, in my case an ability to browse downloaded site is not required, only properly named attached files are required.
Oleg Chernavin 07/28/2015 07:05 am
Please use my advice and then the Export Files button. Choose the folder to copy files to and check the "Add standard extensions" box.

Oleg.
User 07/28/2015 09:24 am
I already did exactly that without success. I performed the following:
1. I added Additional=SkipDisposition below project URL http://bugzilla.sudo.ws/attachment.cgi?id={:255..265} (I am using this link as a test example, the real web address is different).
2. I switched off Substitution rule.
3. I downloaded the project. Several files with names
attachment.cgi@id=255
...
attachment.cgi@id=265
were created in C:\download\bugzilla.sudo.ws folder.
4. I performed Export Files with checked "Use standard extensions for files with known file types" option.

After that, there are the same files as above in C:\Export\bugzilla.sudo.ws folder, no extensions and no prefixes were added.
Oleg Chernavin 07/28/2015 10:44 am
I need to have the real address to download such files and reproduce the issue. Can you please give it to me?

Oleg.
User 07/28/2015 11:49 am
It is possible to reproduce the steps using http://bugzilla.sudo.ws/attachment.cgi?id={:255..265} with the same results. It is a "test" in a sense that content of this server is not needed, but results are the same.
Oleg Chernavin 07/28/2015 05:42 pm
Yes, I tested and all these URLs return text/plain MIME type, not Word documents, ZIPs, etc. Can you give me other URLs to test.

Oleg.
User 07/29/2015 07:06 am
But the result is the same: real attached documents are not saved with their real extensions and prefixes. In above example, there are files with extensions .diff, .patch, .py, .not. But these extensions are not created for downloaded files.
User 07/29/2015 07:43 am
Exactly the same happens also with the link
https://bug680351.bmoattachments.org/attachment.cgi?id=554308
Oleg Chernavin 07/29/2015 08:18 am
In this case you need to use the standard method - which you used the very first time. If you noticed duplicate files with the same names but different URLs, please let me know some examples.

Offline Explorer contains protection against such cases, but I want to double-check it.

Thank you!

Oleg.
User 07/29/2015 08:45 am
Yes, I can see that there is a protection against duplicates. For example, a suffix _0A93F90350 is added to the second of "percent_h.diff" files with identical name.

But the original problem is not about duplicates, it is about intelligent naming of any downloaded files (including duplicates).

Is it correct that such intelligent naming in this case (according to the description in my first message) is not possible?
Oleg Chernavin 07/29/2015 04:39 pm
I see. Sorry, it is impossible to do so far.

Oleg.