PDA

View Full Version : Multiple file downloads with Miva


yvonner
01-09-07, 12:12 PM
Hi,

I want my users to be able to select files they want to download from the server and then download them in one go. The files they want to download are in a Miva database. Ideally, when they are ready to download, they should be able to choose if they want to zip them into one archive. If they decide unzipped they should only have to choose the destination folder once, not for every file. And a status information screen would be great.

How can I do this with Miva? Can anyone point me to scripts I can download/purchase that will help me with this.

Server environment is Suse 9 with Miva 5.06.

Many thanks,

Yvonne

Vic - WolfPaw Computers
01-09-07, 04:49 PM
Which version of MIVA Merchant are you running?

yvonner
01-10-07, 12:58 AM
Sorry, I wasn't clear. This is not a Merchant application. If I've posted on the wrong forum, please let me know.

Thanks,

Yvonne

Vic - WolfPaw Computers
01-10-07, 01:37 AM
Is it a MIVA Script application?

Perhaps if you elaborate what language you're working in or what application...we might either be able to offer help or direction.

Sorry, I wasn't clear. This is not a Merchant application. If I've posted on the wrong forum, please let me know.

Thanks,

Yvonne

yvonner
01-10-07, 02:57 AM
Yes, an in-house application developed in Miva script, compiled with v5.04 and running under virtual machine V5.06 under Suse v9. It's a fairly simple document management system. The users choose what documents they want to download and we store this list in a Miva database - when they've finished selecting, we'd like a method to download all in one shot

mvmarkus
01-10-07, 12:32 PM
Hi Yvonne,

There used to be at least one script available that I remember, but I guess that one got lost with the old mailinglist. It was at least 4 or 5 years ago, on the old Mivascript list. Maybe you can find this in the archives (but again you'll have to go way back...).

Technically, it is of course possible to write in Mivascript, if you are interested, I may be able to help you with this. Contact me offlist, if you want.

Markus

talamar
01-10-07, 03:34 PM
I have a follow on to this, as I'm doing something similar, though, I am doing it in conjunciton with the store. I have a page that shows URLs for e-books a user can download. The books are stored in a MIVA MySQL database in the store (customer table in store with a customer module). When the user clicks on the link, I want to generate a page that basically says:

Content-Type: application/download-x
Content-Disposition:attachment;filename=file.pdf

<start sending binary>

The issue I'm seeing is it looks like the store pages automatically send a Content-Type: text/html which results in my page just shwing up as text, not pretty.

I tried to move the delivery out of the store to a standalone MIVA script file, but the results are the same, I see the Content-* headers in my browser, followed by binary gobble-dee-gook.

Is there a way to do this in Miva/Miva Merchant or should I just revery back to PERL. I'm trying to keep it in Merchant as I want to validate the user session to make sure we don't have people stealling books.

Scott McCollough
01-11-07, 10:20 PM
I have done similar things with transmitting XML files via MivaScript. The concept is the same but it here is the key for XML. The first three lines of code for the file must read
<MIVA STANDARDOUTPUTLEVEL="">
<MvASSIGN NAME = "l.null" VALUE = "{ miva_output_header( 'Content-Type', 'application/xml' ) }">
<MvEVAL EXPR = "{ '<?xml version="1.0" encoding="iso-8859-1"?>' $ asciichar( 10 ) }">
First, make sure the no extra spaces appear. If any extra spaces sneak out, you cannot change the content type.

Next, use the miva_output_header() to change the content type. In my case it was to make it look like an XML transmission (like an RSS feed).

Last, you start eval'ing out your content. Once again, in my case I was transmiting XML so I sent out the standard XML header. From here I do database lookups, while loops, whatever.

Hopefully this gets you going on the right path.

/Scott

talamar
01-11-07, 11:22 PM
Thanks Scott, this looks like what I need. My only issue would be if I can then do an <mvt:item> in a Merchant template and still get it to work. I'll give it a try.

talamar
01-15-07, 07:52 AM
Well, I can get a regular MIVA script to do it, even when you call the script directly from Merchant via a URL. WhatI can't get to work is putting it in a module and using an <mvt:item> tag to do it. I want to do this so I can test and verify that the user is logged in and has a valid session without rewriting the whole cookie mgmt system. Any ideas on how to get this to work inside a Page Template in Merchant?

Scott McCollough
01-16-07, 08:02 PM
I don't think that is currently possible. I checked out a couple of my test stores and all of them have a number of lines with blank spaces before the first <html> in the template system. And as I stated before, once anything gets output you can no longer change the content type.

I can put in a bug that Miva Merchant needs to remove all white space from being output so that you can do content type changes.

/Scott

talamar
01-16-07, 11:40 PM
Thanks, would be interesting to see if that is possible with an MVT tag or if I will have to embed the content type in the template. For future reference, you can do this:

<MvIF EXPR="{l.test eq 1}">
<MvASSIGN NAME = "l.null" VALUE = "{ miva_output_header( 'Content-Type', 'application/pdf' ) }">
<MvELSE>
<MvASSIGN NAME = "l.null" VALUE = "{ miva_output_header( 'Content-Type', 'text/html' ) }">
</MvIF>
<MvIF EXPR="{l.test eq 1}">
...print pdf file...
<MvELSE>
..print file not found in html/head/body formatted form
</MvIF>