• Resolved akalsha

    (@akalsha)


    Hello,

    I’m hoping you might be able to help with this, please. I’m not sure if this plugin is a solution, but thought I’d ask because you work for Dreamhost. I currently have a web site hosted with Dreamhost, and I have a LOT of downloadable content (videos, audio files). Dreamhost support has asked me to offload some of the files to Dreamobjects, or some other file sharing service.

    I’m fine with doing that, but in looking at the wikis for DreamObjects, I can’t see how I would go about doing this. Coding links on the web pages of my site to individual files stored in Dreamobjects is not an option, due to the number of them. I would like it if site visitors could browse the files, which are organized into various folders, and download what they want. Is that possible with DreamObjects? Would this plugin help with that? If you can help me at all, I’d greatly appreciate it as I can’t see how DreamObjects is going to work for me, and I’d prefer to keep everything with Dreamhost.

    Sincerely,
    Heather

    https://wordpress.org/plugins/dreamobjects/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    This isn’t the plugin solution you’re looking for (insert Jedi joke here) BUT …

    These aren’t files already included in your blog is it? They’re just a bunch of files in a folder?

    If so, sadly you’re looking for something like this: http://code.tutsplus.com/tutorials/how-to-use-amazon-s3-php-to-dynamically-store-and-manage-files-with-ease–net-31

    That MIGHT be able to do what you’re looking for if I understand it correctly. If not, let me know, I’m happy to see if I can untangle this 🙂

    Thread Starter akalsha

    (@akalsha)

    Hello,

    Thank you for helping, even though this particular plugin isn’t the solution. I really appreciate it.

    The files are currently part of the WordPress blog via a download management plugin, but I can easily trash that plugin, and do something else. All of the files are in one main folder on the server, with organizational sub-folders.

    I checked out the tutorial you linked to. I don’t want users to be able to upload files, so I’m not sure if that is the best solution? I just want people to be able to download the files via a simple directory interface on the web site.

    Ideally, I just want people to be able to browse the contents of the folder, and sub-folders, and download any of the files. That’s how the web site is currently set up. But, Dreamhost wants me to move the media files from the regular web server to either DreamObjects, or some other file storage-type service. I have no idea how to accomplish what I want to do with DreamObjects.

    I guess if I have to, I can just use Microsoft OneDrive, Google Drive, or something, and make public folders and subfolders. I’d rather have the files be a part of my web site, though, instead of sending site visitors to a folder on OneDrive or Google Drive. I’d also rather pay Dreamhost for the file storage, rather than give my money to Microsoft or Google. I don’t see an easy solution with Dreamobjects,though.

    Any help would be greatly appreciated.

    Thank you,
    Heather

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The files are currently part of the WordPress blog via a download management plugin,

    That should be permitted to remain on your site then, per DreamHosts’ TOS (I recall we sent out “Hey, stop storing files on your server if they’re not being used” for high disk usage folks). But that may depend on HOW you use them.

    I checked out the tutorial you linked to. I don’t want users to be able to upload files, so I’m not sure if that is the best solution? I just want people to be able to download the files via a simple directory interface on the web site.

    Oh sure, then just leave off the part about the upload 🙂

    I made a quick fork of the S3.php file – https://github.com/Ipstenu/dreamobjets-php-class – so it’s already set up for DreamHost.

    <?php
    
    //include the S3 class
    if (!class_exists('S3'))require_once('S3.php');
    
    //AWS access info
    if (!defined('awsAccessKey')) define('awsAccessKey', 'MYACCESSKEY');
    if (!defined('awsSecretKey')) define('awsSecretKey', 'MYSECRETKEY');
    
    //Bucket Info
    $bucketName = 'MYBUCKETNAME';
    
    /* STOP EDITING HERE */
    
    //instantiate the class
    $s3 = new S3(awsAccessKey, awsSecretKey);
    
    // Get the contents of our bucket
    $bucket_contents = $s3->getBucket($bucketName);
    
    foreach ($bucket_contents as $file){
    
        $fname = $file['name'];
        $furl = 'http://'.$bucketName.'.objects.dreamhost.com/'.$fname;
    
        //output a link to the file
        echo '<a href=\'$furl\'>$fname</a><br />';
    }

    Looks like this from the user end: http://ipstenu.org/dreamobjects

    Thread Starter akalsha

    (@akalsha)

    Thank you. Hopefully I can do this. So, DreamObjects itself doesn’t have a browsable web interface for when a bucket is made public?

    I really have no idea what to do with anything on that github page that you linked to. It’s Greek to me. I feel like I’m doomed to end up sharing the files from Google Drive, which is depressing and frustrating. I know html, and I can do minor tweaks to pre-made php programs (like WordPress), but I think this whole DreamObjects thing is a little over my head. I wish they would provide options for non-programmers. Dreamhost won’t let me keep the files as they are. I wish they would. So, I guess unless I can figure out this whole DreamObjects thing, it’s Google Drive for me.

    Is it just a matter of creating a php page, and inserting the above code? I understand I’d have to amend it with the actual bucket names,etc.

    I guess I’ll have to mess with it. Feeling stupid, and disheartened. I’ve had the site the way it is now for ten years, and am now having the rug pulled out from under me.

    Thank you very much for your help.

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    If you download the S3.php file I linked you to on github and then take the code in my previous post and put that in an index.php file, and put them both in the same Location on your site, it’ll make a browsable listing.

    But no, there isn’t a built in top-down browsable interface for visitors. You, yes, obviously, you’ve seen our admin. It’s a little more like Dropbox, in that the files are default to be private.

    It’s kind of how Ceph (the underlying code base) works. The idea is that you have storage and link to it when you need it, not that it’s a browsable directory for anyone to surf and download.

    Thread Starter akalsha

    (@akalsha)

    Hi Mika,

    I’m sure that I’m doing something wrong, but the S3.php file, and the above code are not working for me. In the above code, in this section:
    //AWS access info
    if (!defined(‘awsAccessKey’)) define(‘awsAccessKey’, ‘MYACCESSKEY’);
    if (!defined(‘awsSecretKey’)) define(‘awsSecretKey’, ‘MYSECRETKEY’);

    I’m replacing MYACCESSKEY with the S3 key in Dreamobjects, and replacing MYSECRETKEY with the key that shows up when you click “show secret key” in Dreamobjects.

    Then, I replaced MYBUCKETNAME with the name of the bucked I created. That’s all I changed. Is that correct?

    I created an index.php with the above code in it, and uploaded to a new test folder on my server which I created, along with the S3.php file. When I browse to it, I get a page with this text/links on it:
    $fname
    $fname
    $fname
    $fname
    $fname
    $fname

    The links all point to the folder name/$furl

    Do you know what I’ve done wrong?

    Thread Starter akalsha

    (@akalsha)

    Hello,
    I just realized that, while the bucket is public, the files within were not. Does one have to click on every single file in a bucket,and make them public? Is there a way to set it so that everything in a bucket is public automatically?

    I changed all of the files to be public, and refreshed the page, and now I have a new problem. The page is showing php errors:

    Warning: S3::getBucket(): [403] Unexpected HTTP status in (path to file)/S3.php on line 355

    Warning: Invalid argument supplied for foreach() in (path to file)index.php on line 21

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    What client are you using to do the uploads? There should be a way to set the public/private value in there.

    Is the s3 file named S3.php with the capital S?

    Thread Starter akalsha

    (@akalsha)

    Hello,

    I’m just using the Dreamobjects web interface right now. I only have a handful of files in the bucket to test it out. Just trying to figure out how to make this work before I put all the files in there. Once I get a web interface working to display the files, I’ll pick out a client, etc. That’s good that the clients have ability to set the public/private values! I was worried that I was going to have to manually set values for every single file.

    Yes, the S3.php file has a capital S.

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I’m honestly not sure, and it’s not really an aspect of the plugin. The code works on my setup…

    Is the bucket listed as private? That’s about the only thing I can think of.

    Thread Starter akalsha

    (@akalsha)

    Hi Mika,

    The bucket is public. I just re-tried to set up the above S3.php and index page files, and now the resulting web page is just completely blank. I feel like I’m just doing something wrong, but don’t know what. Would you be willing to tell me specifically what steps I should take in order to get the S3.php file working, please? I completely understand if you don’t want to, or don’t have time.

    As far as downloading the S3.php file, is there a better way to do it instead of copying and pasting the code? When I go to this page https://github.com/Ipstenu/dreamobjects-php-class

    I tried right clicking on the S3.php link, and selected download as, and saved the S3.php file. When I browsed to the folder I uploaded that S3.php file to and the index. php file, it was a duplicate of the https://github.com/Ipstenu/dreamobjects-php-class page.

    Next, I went to this page https://github.com/Ipstenu/dreamobjects-php-class/blob/master/S3.php

    and copied the 2361 lines, and pasted them into a blank file, and saved as S3.php, and that’s when I get the blank web page.

    Should I be editing any of the S3.php code?

    For the index page, In the above code which you posted, in this section:
    //AWS access info
    if (!defined(‘awsAccessKey’)) define(‘awsAccessKey’, ‘MYACCESSKEY’);
    if (!defined(‘awsSecretKey’)) define(‘awsSecretKey’, ‘MYSECRETKEY’);

    I’m replacing MYACCESSKEY with the S3 key in Dreamobjects, and replacing MYSECRETKEY with the key that shows up when you click “show secret key” in Dreamobjects.

    Then, I replaced MYBUCKETNAME with the name of the bucked I created. I’m not changing anything else.

    Should I have html headers in these files? Or is it ok for them to start right out with <?php ?

    Sincerely,
    Heather

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    It’s fine to have the page start with <?php. And no, you shouldn’t need to edit the S#.php file.

    At this point, you’d want to check your PHP error logs (on DreamHost they’re at /home/user/logs/domain.com/http/error.log ) and see if something about that page shows up.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to allow site visitors to browse and download files’ is closed to new replies.