/// <summary>
 /// Set Object Metadata
 /// </summary>
 /// <param name="objectName"></param>
 /// <param name="objectMetadata">Object metadata</param>
 /// <returns></returns>
 public void SetObjectMetadata(string objectName, ObjectMetadata objectMetadata)
 {
     if (objectName != null)
     {
         objectName = objectName.Trim('/');
     }
     if (String.IsNullOrEmpty(objectName))
     {
         throw new ArgumentNullException("objectName");
     }
     if (objectMetadata == null)
     {
         throw new ArgumentNullException("objectMetadata");
     }
     try
     {
         string fullFileName = GetFullFileName(objectName);
         if (File.Exists(fullFileName))
         {
             objectMetadata.ContentType = MimeUtils.Instance.GetMimeByFileExt(Path.GetExtension(objectName));
             var metadataStore = new LocalFSMetadataStore(fullFileName + metadataFileExt);
             metadataStore.Save(objectMetadata);
         }
     }
     catch (Exception ex)
     {
         throw new StorageIOException("Set object metadata fail!", ex);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="objectName"></param>
 /// <param name="content"></param>
 /// <param name="overrideIfExists"></param>
 /// <param name="objectMetadata"></param>
 public void PutObject(string objectName, Stream content, bool overrideIfExists, ObjectMetadata objectMetadata = null)
 {
     if (objectName != null)
     {
         objectName = objectName.Trim('/');
     }
     if (String.IsNullOrEmpty(objectName))
     {
         throw new ArgumentNullException("objectName");
     }
     if (content == null || content == Stream.Null)
     {
         throw new ArgumentNullException("content");
     }
     try
     {
         string fullFileName = GetFullFileName(objectName);
         string dirPath      = Path.GetDirectoryName(fullFileName);
         if (!Directory.Exists(dirPath))
         {
             DirectoryInfo di = new DirectoryInfo(dirPath);
             di.Create();
         }
         if (overrideIfExists || !File.Exists(fullFileName))
         {
             FileInfo fi = new FileInfo(fullFileName);
             using (FileStream fs = fi.Create())
             {
                 content.CopyTo(fs);
                 fs.Flush();
                 fs.Close();
             }
             if (objectMetadata == null)
             {
                 objectMetadata = new ObjectMetadata();
             }
             objectMetadata.ContentLength = content.Length;
             objectMetadata.ContentType   = MimeUtils.Instance.GetMimeByFileExt(Path.GetExtension(objectName));
             var metadataStore = new LocalFSMetadataStore(fullFileName + metadataFileExt);
             metadataStore.Save(objectMetadata);
         }
     }
     catch (Exception ex)
     {
         throw new StorageIOException("Put object fail!", ex);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="objectName"></param>
 /// <returns></returns>
 public ObjectMetadata GetObjectMetadata(string objectName)
 {
     if (objectName != null)
     {
         objectName = objectName.Trim('/');
     }
     if (String.IsNullOrEmpty(objectName))
     {
         throw new ArgumentNullException("objectName");
     }
     try
     {
         string fullFileName = GetFullFileName(objectName);
         if (File.Exists(fullFileName))
         {
             ObjectMetadata metadata = new ObjectMetadata()
             {
                 ContentType = MimeUtils.Instance.GetMimeByFileExt(Path.GetExtension(objectName)),
             };
             var metadataStore = new LocalFSMetadataStore(fullFileName + metadataFileExt);
             metadataStore.Load(ref metadata);
             return(metadata);
         }
         else
         {
             throw new StorageObjectNotFoundException("Storage object not found!", objectName);
         }
     }
     catch (StorageObjectNotFoundException notFound)
     {
         throw notFound;
     }
     catch (Exception ex)
     {
         throw new StorageIOException("Get object metadata fail!", ex);
     }
 }