From bc456509ced6a2a2fcb1d8e62422c5790165c5e3 Mon Sep 17 00:00:00 2001 From: Michael Cortez Date: Sat, 4 Nov 2006 00:41:11 +0000 Subject: [PATCH] Batch upload tool, for uploading directories of images. Used for testing asset upload code. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@497 52acb1d6-8a22-11de-b505-999d5b087335 --- .../IA_MultiImageUpload.csproj | 61 ++++++++++++++ .../IA_MultiImageUpload/MultiImageUpload.cs | 83 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 33 ++++++++ 3 files changed, 177 insertions(+) create mode 100644 libsecondlife-cs/examples/IA_MultiImageUpload/IA_MultiImageUpload.csproj create mode 100644 libsecondlife-cs/examples/IA_MultiImageUpload/MultiImageUpload.cs create mode 100644 libsecondlife-cs/examples/IA_MultiImageUpload/Properties/AssemblyInfo.cs diff --git a/libsecondlife-cs/examples/IA_MultiImageUpload/IA_MultiImageUpload.csproj b/libsecondlife-cs/examples/IA_MultiImageUpload/IA_MultiImageUpload.csproj new file mode 100644 index 00000000..88ce546d --- /dev/null +++ b/libsecondlife-cs/examples/IA_MultiImageUpload/IA_MultiImageUpload.csproj @@ -0,0 +1,61 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8598E42A-DCBC-4224-9503-5694F17B2F45} + Exe + Properties + IA_MultiImageUpload + IA_MultiImageUpload + + + true + full + false + ..\..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A} + IA_ImageTool + + + {E464B963-46E3-4E1A-A36F-9C640C880E68} + IA_SimpleInventory + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_MultiImageUpload/MultiImageUpload.cs b/libsecondlife-cs/examples/IA_MultiImageUpload/MultiImageUpload.cs new file mode 100644 index 00000000..e82634f1 --- /dev/null +++ b/libsecondlife-cs/examples/IA_MultiImageUpload/MultiImageUpload.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using IA_SimpleInventory; +using IA_ImageTool; + +using libsecondlife; +using libsecondlife.InventorySystem; +using libsecondlife.AssetSystem; + +namespace IA_MultiImageUpload +{ + class MultiImageUpload : SimpleInventory + { + protected string ImageDirectory; + + static new void Main(string[] args) + { + if (args.Length < 4) + { + MultiImageUpload.Usage(); + return; + } + + string fullpath = Path.GetFullPath(args[3]); + + if (!Directory.Exists(fullpath)) + { + Console.WriteLine("Directory does not exist: " + fullpath); + return; + } + + MultiImageUpload app = new MultiImageUpload( fullpath ); + app.Connect(args[0], args[1], args[2]); + app.doStuff(); + app.Disconnect(); + } + + public MultiImageUpload(string dir) + { + ImageDirectory = dir; + } + + public static void Usage() + { + System.Console.WriteLine("MultiImageUpload [FirstName] [LastName] [Password] [Directory]"); + } + + protected new void doStuff() + { + InventoryFolder iFolder = AgentInventory.getFolder("Textures"); + iFolder = iFolder.CreateFolder(Helpers.GetUnixTime().ToString()); + + Console.WriteLine("Uploading images:"); + + string[] files = Directory.GetFiles(ImageDirectory, "*.tif"); + + int filesUploaded = 0; + foreach (string file in files) + { + byte[] j2cdata = null; + try + { + j2cdata = KakaduWrap.ReadJ2CData(file); + } catch ( Exception e ) + { + Console.WriteLine(e.Message); + } + if ( j2cdata != null ) + { + Console.WriteLine(file); + iFolder.NewImage(Path.GetFileName(file), "ImageTool Upload", j2cdata); + + if (++filesUploaded >= 20) + { + break; + } + } + } + } + } +} diff --git a/libsecondlife-cs/examples/IA_MultiImageUpload/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/IA_MultiImageUpload/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..70a2e174 --- /dev/null +++ b/libsecondlife-cs/examples/IA_MultiImageUpload/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IA_MultiImageUpload")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IA_MultiImageUpload")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("48d68a03-089b-4c01-90ce-4526c7cc615d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]