You can use the "Package files from other products" setting for products that should issue a file you've already uploaded to another product -- see Approach B here:
This help page explains how to set up Discount Codes:
If you want to issue buyers a Discount Code when they purchase a given product, you can put that in the product's thank-you email (Email Message field of the product's settings). If you want to issue each buyer a unique discount code that can only be used once, that would be similar to selling Gift Coupons as explained here:
The difference would be that you might prefer to set the discount to markdown a particular product's per-unit price by a certain amount (rather than take a flat amount off any order), and instead of creating a separate Gift Coupon product, you'd enable "Send Stored Codes" for each download product and paste in a subset of the list of Discount Codes you created (i.e., to prevent issuing duplicate codes to multiple buyers, do not paste the same list of codes for multiple products).
You might wish to Enable Templated Email for each product, so you can provide a custom Email Message template that would replace our standard link/code presentation in thank-you emails, giving you more control over how the link and code is presented to the buyer: