Пример #1
0
        protected override void Initialise(CommandLine cl)
        {
            if (cl.args.Count != 2)
            {
                // TODO We should probably allow multiple file names on the command line
                if (Utils.IsLinux)
                {
                    throw new SyntaxException("The put command requires two parameters. Did you remember to escape wildcard parameters?");
                }
                else
                {
                    throw new SyntaxException("The put command requires two parameters");
                }
            }

            keyArgument  = cl.args[0];
            fileArgument = cl.args[1];

            acl          = Acl.GetOptionParameter(cl, typeof(Acl), false);
            backup       = cl.options.ContainsKey(typeof(Backup));
            sync         = cl.options.ContainsKey(typeof(Sync));
            big          = cl.options.ContainsKey(typeof(Big));
            sub          = cl.options.ContainsKey(typeof(Sub));
            storageClass = StorageClass.GetOptionParameter(cl, typeof(StorageClass), false);

            if (sub)
            {
                subWithDelete = (cl.options[typeof(Sub)] as Sub).withDelete;
            }

            if (big && sub)
            {
                throw new SyntaxException("The /big option is not currently compatible with the /sub option");
            }

            if (big && sync)
            {
                throw new SyntaxException("There is no need to specify the /sync option with the /big option because /big uses checksums to upload only the chunks that need to be uploaded");
            }

            if (big)
            {
                Big bigOption = (Big)cl.options[typeof(Big)];
                perChunkBytes = (long)(bigOption.chunkMegabytes * 1024.0 * 1024.0);
            }

            int slashIdx = keyArgument.IndexOf("/");

            if (slashIdx == -1)
            {
                baseKey = "";
                bucket  = keyArgument;
            }
            else
            {
                baseKey = keyArgument.Substring(slashIdx + 1);
                bucket  = keyArgument.Substring(0, slashIdx);

                if (sub && !baseKey.EndsWith("/"))
                {
                    throw new SyntaxException("With the /sub option, either specify a bucket name only or a key that ends with a slash (/)");
                }
            }
        }