News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Is there a way to add a download link from my FTP server & make it members only?

Started by ivanTW, November 10, 2014, 10:32:15 PM

Previous topic - Next topic

ivanTW

Hi

I'm looking to add a link such as www.google.com to only appear for logged in members. The reason for this is I have large music file downloads and they are too large for attachments so I uploaded them to my server, but if I use a regular link, guests can download as well and I'd like for it to be only logged in members. Is there a way I can make this work? I think I've seen something to this effect on other forums where it displays a message "must be logged in to download" where the download link will be once they log in.

Does anyone have an idea on how to do this? or maybe how to have larger attachments? My attachments are 300MB average size. That's why I'm using the FTP link process.

Thanks for any help.

-Ivan

Sir Osis of Liver

Simplest way is to place the links in a board that's only visible to logged in members or specific membergroups.
When in Emor, do as the Snamors.
                              - D. Lister

Arantor

The short answer is 'not really over FTP'. While in theory you could tie authentication into FTP, it's *really* not a good idea for a bunch of reasons, mostly because FTP is a terrible protocol and cannot easily be integrated into the forum.

Hiding a link doesn't magically prevent it from working, it just hides it. Unless the link itself has authentication requirements, anyone could just copy/paste it into a private message or similar.

As far as solutions for larger files goes, there's a real shortage of them at present, though I know there's a gallery software coming soon that could handle such files without completely falling over (but it's not finished yet)
Holder of controversial views, all of which my own.


Sir Osis of Liver

I have allowed users to download mp3s (3-10 mb) from direct links on websites, no problems.  Just tried it here in preview, right click on the link and save as.  Don't know how it would work with 300 mb files on shared server.
When in Emor, do as the Snamors.
                              - D. Lister

Arantor

It primarily depends whether you're doing authentication on it or not.

No authentication, you can store the file directly on the webserver and Apache will take care of it without any problems - even for large files.

If you want auth, though, things get a lot trickier - especially if you're trying to tie it to, say, SMF authentication credentials since you have to cope with PHP limits. No stock server is going to handle 300MB through a single 30 second window to serve the file, simply because most users won't download 300MB in that 30 seconds.

There are solutions to this which involve sending the file in chunks but this is not supported by SMF out of the box; the largest attachment I've ever managed to get working successfully in SMF is about 10MB before I was falling foul of one or other server limits (be it either the 30 second limit or the Apache timeouts), which is why I had to spend time investigating things like sending 206 headers and byte ranges. It's doable even on shared servers but it requires a serious time investment (fortunately, my gallery has had that time investment ;D)
Holder of controversial views, all of which my own.


Kindred

well - until your gallery is released, vbgamer does have a downloads mod...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Yes, he does. However just taking a quick look at Downloads_DownloadFile() in the current version (since I have a licence for the entire suite)...

1. It doesn't attempt to handle timeouts in the manner outlined (so both PHP's and/or Apache's timeouts can be tripped with larger files)
2. Large files will require changing the PHP max upload settings.
3. It advertises byte range support but fails to support it if a client requests it. Resuming downloads is basically not a thing in this case. For larger downloads this is problematic.
4. The actual file serving code is basically identical to SMF's attachment serving code from before 2.0 RC3 or RC4, including the whole thing of transcoding line endings in files (something made optional and off by default in 2.0), which means it is geared towards files under 4MB rather than larger files.
5. It doesn't handle caching properly. Neither Last-Modified-Since nor E-Tag are handled even though the required data is made available to the client.

I would have to suggest, at this time, that the downloads mod is not suited for this purpose. Neither, incidentally, is the gallery since it is geared primarily to images (though current versions now integrate the video addon) and store the file directly in the filesystem and serve it that way, meaning that you can share the link and the file will be accessible. Same deal with SMF Packs' multimedia gallery.

Aeva doesn't make the file directly available, but has some of the same issues as above.

File serving properly with authentication is ridiculously complicated :(
Holder of controversial views, all of which my own.


ivanTW

Thanks for all of the replies! great discussion. It looks like adding the file link to a hidden board is the best option right now. Thanks Krash! If you find out any other way Arantor, let me know. It appears that you have a good grasp on this subject. The files are all zipped, so timeout may not be an issue even though they are 200+MB and I have already changed my PHP upload and timeout limits on my server. Not sure if that will  effect each member's download process.

Thanks for the knowledge, I'll see how the Hidden Board option works, even though I see it's not completely discreet.

Arantor

No, timeout WILL be an issue even if you changed PHP's configuration since there are *other* timeouts that occur which cannot be changed so easily and nor should they since they can cause a denial of service to your hosting plan. I could reliably reproduce timeouts on my localhost with files smaller than 100MB. The *only* reliable way to handle this stuff is with handling it in chunks when you're doing it with PHP.

I already have another way - the gallery I'm building can already handle all of the concerns I mentioned, it's just missing other key features that you will need (like ability to edit albums, edit items, as well as things like searching), but the whole upload/download part of it is pretty darn solid (except for large files with Flash, not so much, but I'm not currently able to debug that properly on this borrowed laptop)
Holder of controversial views, all of which my own.


ivanTW

QuoteI already have another way - the gallery I'm building can already handle all of the concerns I mentioned, it's just missing other key features that you will need (like ability to edit albums, edit items, as well as things like searching), but the whole upload/download part of it is pretty darn solid (except for large files with Flash, not so much, but I'm not currently able to debug that properly on this borrowed laptop)

So, whenever this mod is ready let us know. For me, in this scenario, I have 1 zip file that needs to be uploaded, no searching, not large parts, just one large zip file, and I was looking for it to be accessible to members only via it showing once they log in to the forum. If I'm misunderstanding, and this is already capable in your mod, let me know where it's accessible.

Thanks for your insights.

Arantor

I won't be selling it until it is actually usable for general users.
Holder of controversial views, all of which my own.


Sir Osis of Liver

Quote from: ivanTW on November 11, 2014, 12:31:03 PM
I have already changed my PHP upload and timeout limits on my server.

On some shared hosts, you can change upload and timeout limits in php.ini, the changes will apply, but they will revert back to max settings allowed by the host.
When in Emor, do as the Snamors.
                              - D. Lister

Advertisement: