Including Image Details on UploadImage

Jul 25, 2011 at 9:54 PM

How do I include details like Keywords, Lat/Lon, Caption, Hidden Flag on the upload of the image?

I can't find anything currently exposed to allow me to add them.  I noticed that the hidden flag isn't currently being checked for in the headers.add statements. However the others are... so how do I pass them the details?

To get around it for now, at least on the Keywords property, I've created another overload, and modified the final overload to accept it:

        /// <summary>
        /// Uploads a file
        /// </summary>
        /// <param name="fileName">The filename we want to upload</param>
        /// <param name="keywords">keywords for the file</param>
        /// <returns>An Image object that describes the image we uploaded</returns>
        public Image UploadImage(string fileName, string keywords)
        {
            var byteArr = File.ReadAllBytes(fileName);
            var MD5Sum = GetStringFromHash(System.Security.Cryptography.MD5.Create().ComputeHash(byteArr));

            return UploadImage(fileName, MD5Sum, keywords);
        }

Thanks for the great interface by the way

Developer
Jul 25, 2011 at 10:04 PM

Here is what I started writting: "The ImageUpload class has a property Keywords and that property is being sent to SmugMug as part of the upload. Can you try setting that property when after you instantiate the ImageUpload class? And then calling the UploadImage method?"

And then it hit me! Those properties are marked private! Dang!

I can't think of a reason why those properties are private - Maria, any ideas? If there is no strong reason for them to be private we should just make them public.

Good point that the Hidden flag is never passed over to SmugMug - we should fix that!

Alex

Developer
Jul 25, 2011 at 10:18 PM

If we can make the properties public then the code you have to write will look something like this:

var myUpload = myAlbum.CreateUploader();

myUpload.Keywords = "keyword";

myUpload.UploadImage(filePath);

If an overload is added it should allow setting the other properties as well.

Alex

Developer
Jul 25, 2011 at 10:18 PM

If we can make the properties public then the code you have to write will look something like this:

var myUpload = myAlbum.CreateUploader();

myUpload.Keywords = "keyword";

myUpload.UploadImage(filePath);

If an overload is added it should allow setting the other properties as well.

Alex

Jul 26, 2011 at 12:37 AM

In the version that I'm working with, I made those 6 properties public, removed the overload I had setup for the Keywords, and added the add.header line to the UploadImage function.   It is working very nicely now.

I'll create an issue for the official request.

 

Thanks Alex!