Esempio n. 1
0
 public String GetImageKey(ImageUpload imageUpload)
 {
     if (imageUpload != null)
     {
         string[] splitUri = imageUpload.ImageUri.Split(new char[] { '/' });
         return(splitUri[splitUri.Length - 1]);
     }
     else
     {
         throw new ArgumentNullException("imageUpload");
     }
 }
Esempio n. 2
0
        public async Task <ImageUpload> UploadImage(string albumUri, string filePath)
        {
            if (LoginType == LoginType.Anonymous)
            {
                throw new UnauthorizedAccessException("You must be logged in using OAuth to upload an image.");
            }

            if (File.Exists(filePath))
            {
                FileInfo fi           = new FileInfo(filePath);
                byte[]   fileContents = File.ReadAllBytes(fi.FullName);

                ImageUpload response = await UploadImage(albumUri, fi.Name, fileContents, CancellationToken.None);

                return(response);
            }
            else
            {
                throw new FileNotFoundException("Cannot find the file to upload", filePath);
            }
        }
Esempio n. 3
0
        public async Task <Image> GetImage(ImageUpload imageUpload)
        {
            var imageKey = GetImageKey(imageUpload);

            return(await GetImage(imageKey));
        }