Solved Downloading Schematics

Discussion in 'Plugin Development' started by MCMatters, Dec 1, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MCMatters

    I need to download a .schematic file over HTTPS. (schematics are GZIP format)

    Code:
    Code:
    try {
                            URL url = new URL(base+args[1]+".schematic");
                            File dest = new File("plugins/WorldEdit/schematics/"+args[1]+".schematic");
                            if(dest.exists()) dest.delete();
                            dest.createNewFile();
                            BufferedInputStream bis = null;
                            BufferedOutputStream bos = null;
                            try
                            {
                                URLConnection urlc = url.openConnection();
    
                                bos = new BufferedOutputStream(new FileOutputStream(dest));
                                bis = new BufferedInputStream(urlc.getInputStream());
                                int i;
                                while ((i = bis.read()) != -1)
                                {
                                    bos.write(i);
                                }
                            }
                            finally
                            {
                                if (bis != null) {
                                    try
                                    {
                                        bis.close();
                                    }
                                    catch (IOException ioe)
                                    {
                                        ioe.printStackTrace();
                                    }
                                }
                                if (bos != null) {
                                    try
                                    {
                                        bos.close();
                                    }
                                    catch (IOException ioe)
                                    {
                                        ioe.printStackTrace();
                                    }
                                }
                            }
                            try
                            {
                                bos.close();
                            }
                            catch (IOException ioe)
                            {
                                ioe.printStackTrace();
                            }
    My error is that cannot parse into GZIP, can you support me?

    Variables:

    args[1] = "test";
    base = "https://www.example.com/schematics/";
     
  2. Offline

    Mrs. bwfctower

    @MCMatters Please post the stack trace. (for line #, exact exception thrown, etc)
     
  3. Offline

    MCMatters

    @Mrs. bwfctower
    Code:
            at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165) ~[?:1.8.0_51]
            at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79) ~[?:1.8.0_51]
            at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91) ~[?:1.8.0_51]
            at com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat$1.getReader(ClipboardFormat.java:56) ~[worldedit-bukkit-6.1.jar:?]
            at com.sk89q.worldedit.command.SchematicCommands$1.execute(SchematicCommands.java:123) [AsyncWorldEditInjector.jar:?]
            at org.primesoft.asyncworldedit.injector.async.AsyncJobProcessor$1.doRun(AsyncJobProcessor.java:139) [AsyncWorldEdit.jar:?]
            at org.primesoft.asyncworldedit.worldedit.BaseTask.run(BaseTask.java:138) [AsyncWorldEdit.jar:?]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) [spigot_oppvp.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53) [spigot_oppvp.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_51]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_51]
            at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
     
  4. Offline

    Scimiguy

    The whole stacktrace
     
  5. Offline

    MCMatters

    @Scimiguy that's all, its just saying the file isn't in GZIP format.
     
  6. Offline

    Chloe-chan

    I don't think that's the full error stack trace. It's missing the exception thrown and stuff.
     
  7. Offline

    MCMatters

  8. Offline

    mcdorli

    This should have a section with the text "Caused By: etc". Please, post that and the next line, or the whole latest.log
     
  9. Offline

    teej107

    @MCMatters When we say stacktrace, we mean the whole stacktrace! We can (and you should be able to) read a full stacktrace and filter out the not so important parts of it.
     
  10. Offline

    MCMatters

  11. Offline

    mcdorli

    1.: You don't seem to understand, what "whole" means Sinonyms: all of; entire.
    2.: The file isn't in GZIP format, I guess it means a .gzip for the extension.
     
  12. Offline

    Mrs. bwfctower

    @MCMatters My guess is that the world (schematic) is corrupt, which basically means that the formatting of the actual file is not to GZIP standards.

    EDIT: Try using URLConnection#setProperty("Accept-Encoding", "gzip")
     
  13. Offline

    MCMatters

    @mcdorli that is the whole exception..
     
  14. Offline

    mythbusterma

    @MCMatters

    Regardless, we told you what your issue is.
     
Thread Status:
Not open for further replies.

Share This Page