[lib] Mediafire Library - Directly download!

Discussion in 'Resources' started by ZeusAllMighty11, Aug 15, 2013.

  1. Offline

    ZeusAllMighty11 BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hey guys,


    This is a library which will allow you to easily upload and download from Mediafire in Java.

    Requirements:
    - Mediafire account (email,password,app id, app key)


    How does it work?
    Although Dropbox is commonly used for filehosting, many still use Mediafire. And as a result, it can be a pain in the butt to go to the mediafire link, enter a captcha (?), and then download. So instead, you don't ever need to open your browser. This could allow things such as auto map/mod downloaders from Minecraftforum, etc.


    How to use it:
    Code:
    /* This generates a 10 minute temporary session so we can have access to uploads/downloads */
    Session sesh = MediafireAPI.getSession("[email protected]", "mypassword", appID, "MyAppKey1278931293");
     
    /* Let's download a file */
    MediafireAPI.download("keyOfFile", new File("./cats.txt"), sesh);
    // keyOfFile  is the file code
    // the second argument is File
    // Third argument is a session which isn't inactive
    
    At the moment I haven't worked on uploading. Also, you will have to already know the file extension, because I can't assume the file you are downloading is txt or a zip or a rar archive. I'd just say use accordingly for now.


    How to be a Mediafire dev:

    1) Login to Mediafire, and click on your profile picture and go to settings
    2) You'll see something like this:

    [IMG]

    3) Click on 'developers'
    4) Click ' create new application'
    5) Enter out info as you wish
    6) When it's finished, click on developers again and you will see your app with your application id and your api key.

    How to find a download code:
    'download code' is the small code in the link of a download.
    An example download would look like:
    https://www.mediafire.com/view/mycodehere/stuffsjaiwoehfaopwefh
    After the 'view' is the download code. This can be obtained with httprequests by parsing the json response


    That's it. I'm still working on the uploading, and the file extension detection, but the downloading works.

    Thanks to @lol768


    Download

    This post has been edited 2 times. It was last edited by TheGreenGamerHD Aug 15, 2013.
  2. Online

    CaptainBern BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  3. Offline

    epicfacecreeper

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Would anything using this be allowed on bukkitdev? It seems like it could be a big security hole. Sending a texturepack seems to be a security risk for some of the staff even.

    This post has been edited 2 times. It was last edited by epicfacecreeper Aug 15, 2013.
  4. Online

    CaptainBern BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  5. Offline

    ZeusAllMighty11 BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @CaptainBern @epicfacecreeper

    I am not positive, but as long as your plugin clearly states exactly what happens and there is a detailed way how to disable it, I believe it would be okay. CoreProtect allows for automatic downloads and it has a toggle.

    To be safe I'd say not to, as it's better just to redirect your users to your plugin page so they can also see a changelog, etc.

    I'll look into it more

Share This Page