@@ -780,6 +780,17 @@ private static Dictionary<string, string> GetContainerMetadataWithPrefix(IObject
780780 return FilterMetadataPrefix ( metadata , prefix ) ;
781781 }
782782
783+ private static string GetObjectContentType ( IObjectStorageProvider provider , string containerName , string objectName )
784+ {
785+ Dictionary < string , string > headers = provider . GetObjectHeaders ( containerName , objectName ) ;
786+
787+ string contentType ;
788+ if ( ! headers . TryGetValue ( "Content-Type" , out contentType ) )
789+ return null ;
790+
791+ return contentType . ToLowerInvariant ( ) ;
792+ }
793+
783794 #endregion
784795
785796 #region Objects
@@ -853,19 +864,23 @@ public void TestUpdateObjectMetaData()
853864 string containerName = TestContainerPrefix + Path . GetRandomFileName ( ) ;
854865 string objectName = Path . GetRandomFileName ( ) ;
855866 string objectData = "" ;
867+ string contentType = "text/plain-jane" ;
856868
857869 ObjectStore result = provider . CreateContainer ( containerName ) ;
858870 Assert . AreEqual ( ObjectStore . ContainerCreated , result ) ;
859871
860872 Stream stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( objectData ) ) ;
861- provider . CreateObject ( containerName , stream , objectName ) ;
873+ provider . CreateObject ( containerName , stream , objectName , contentType ) ;
874+ Assert . AreEqual ( contentType , GetObjectContentType ( provider , containerName , objectName ) ) ;
875+
862876 Dictionary < string , string > metadata = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase )
863877 {
864878 { "Key1" , "Value 1" } ,
865879 { "Key2" , "Value ²" } ,
866880 } ;
867881
868882 provider . UpdateObjectMetadata ( containerName , objectName , new Dictionary < string , string > ( metadata , StringComparer . OrdinalIgnoreCase ) ) ;
883+ Assert . AreEqual ( contentType , GetObjectContentType ( provider , containerName , objectName ) ) ;
869884
870885 Dictionary < string , string > actualMetadata = provider . GetObjectMetaData ( containerName , objectName ) ;
871886 Console . WriteLine ( "Object Metadata" ) ;
@@ -880,6 +895,7 @@ public void TestUpdateObjectMetaData()
880895 { "Key2" , "Value 2" }
881896 } ;
882897 provider . UpdateObjectMetadata ( containerName , objectName , new Dictionary < string , string > ( updatedMetadata , StringComparer . OrdinalIgnoreCase ) ) ;
898+ Assert . AreEqual ( contentType , GetObjectContentType ( provider , containerName , objectName ) ) ;
883899
884900 actualMetadata = provider . GetObjectMetaData ( containerName , objectName ) ;
885901 Console . WriteLine ( "Object Metadata" ) ;
@@ -1311,13 +1327,14 @@ public void TestCopyObject()
13111327 string copiedName = Path . GetRandomFileName ( ) ;
13121328 // another random name counts as random content
13131329 string fileData = Path . GetRandomFileName ( ) ;
1330+ string contentType = "text/plain-jane" ;
13141331
13151332 ObjectStore containerResult = provider . CreateContainer ( containerName ) ;
13161333 Assert . AreEqual ( ObjectStore . ContainerCreated , containerResult ) ;
13171334
13181335 using ( MemoryStream uploadStream = new MemoryStream ( Encoding . UTF8 . GetBytes ( fileData ) ) )
13191336 {
1320- provider . CreateObject ( containerName , uploadStream , objectName ) ;
1337+ provider . CreateObject ( containerName , uploadStream , objectName , contentType ) ;
13211338 }
13221339
13231340 using ( MemoryStream downloadStream = new MemoryStream ( ) )
@@ -1355,9 +1372,8 @@ public void TestCopyObject()
13551372 }
13561373
13571374 // make sure the content type was not changed by the copy operation
1358- Dictionary < string , string > originalHeaders = provider . GetObjectHeaders ( containerName , objectName ) ;
1359- Dictionary < string , string > copiedHeaders = provider . GetObjectHeaders ( containerName , objectName ) ;
1360- Assert . AreEqual ( originalHeaders [ "Content-Type" ] , copiedHeaders [ "Content-Type" ] ) ;
1375+ Assert . AreEqual ( contentType , GetObjectContentType ( provider , containerName , objectName ) ) ;
1376+ Assert . AreEqual ( contentType , GetObjectContentType ( provider , containerName , copiedName ) ) ;
13611377
13621378 /* Cleanup
13631379 */
0 commit comments