Sorry for the confusing title but I tried to condense it as best I could. To clarify, my company offers a set of products that can be downloaded (for free) from our website (the download comes as a zip file). In our products we include some videos that are currently being hosted on our personal server, however we also have the videos being hosted on Vimeo. To cut down on server traffic and download time the question was asked, "Can we just run the video download from Vimeo instead of our own server"? Well the answer that question is yes, in fact Vimeo (if you are a pro member) offers different ways of downloading your own personal videos either through their API or a permanent link within the video's settings. I have decided to go the permanent link route, so going through the video settings Vimeo offers 5 different links, each according to the quality desired (YAY!).
My question, however, is there some way through php or html to create a drop down selection on the download page and depending on which one you select (due to bandwidth, etc.) the content we offer gets downloaded with the video in the correct file structure of our product?
Let me clarify, not along side the downloaded zip, put actually inside of it.
For example, say my file structure looks like this:
Product
Books (folder)
Videos (folder)
Other_content (folder)
index.html (file)
and the video exists at "Product/Videos/example.mp4". The file exists on my server but I would like for the customer to download it from Vimeo instead. Say I have a basic form below:
<form method="post">
<select name="videoQuality">
<option name="formSelect" value="Select">Select...</option>
<option name="formHD1080" value="HD1080">High Definition (1080p)</option>
<option name="formHD" value="HD">High Definition</option>
<option name="formSD" value="SD">Standard Definition</option>
<option name="formMobile" value="Mobile">Mobile</option>
</select>
<br><br>
<input type="submit" name="formSubmit" value="Download">
</form>
Would there be a way to have the option of the form effect the file that gets downloaded in place of "Product/Videos/example.mp4"? and not along side it (only so the customers don't have to mess with the file tree).
Yes, you can load the zip file using jszip. Than download the video using AJAX and add it to the the zip. All of this happens in the browser.
JSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {
if(err) throw err; // or handle err
var zip = new JSZip(data);
var request = new XMLHttpRequest();
request.open('GET', 'https://vimeo.com/link/to/download', true);
request.onload = function() {
var data = request.responseText;
zip.folder('Videos').file('video.mp4', data); // Add the video file
var blob = zip.generate({type:"blob"});
saveAs(blob, "content.zip"); // Present zip as download
};
request.send();
}
code is untested, but should give you enough info to continue :)