@@ -48,6 +48,37 @@ public function testGetUser()
4848 $ this ->assertArrayHasKey ('SecondsLeft ' , $ user_info );
4949 }
5050
51+ public function testUploadFile ()
52+ {
53+ $ file = 'examples/files/test.docx ' ;
54+
55+ $ fileContents = file_get_contents ($ file );
56+ $ crc = hash ('crc32b ' , $ fileContents );
57+
58+ $ result = ConvertApi::client ()->upload ($ file , 'test.docx ' );
59+ $ uploadedContents = file_get_contents ($ result ['Url ' ]);
60+ $ uploadedCrc = hash ('crc32b ' , $ uploadedContents );
61+
62+ $ this ->assertEquals ($ crc , $ uploadedCrc );
63+ }
64+
65+ public function testUploadStream ()
66+ {
67+ $ file = 'examples/files/test.docx ' ;
68+ $ fileContents = file_get_contents ($ file );
69+ $ crc = hash ('crc32b ' , $ fileContents );
70+
71+ $ stream = fopen ('php://memory ' , 'rwb ' );
72+ fwrite ($ stream , $ fileContents );
73+ rewind ($ stream );
74+
75+ $ result = ConvertApi::client ()->upload ($ stream , 'test.docx ' );
76+ $ uploadedContents = file_get_contents ($ result ['Url ' ]);
77+ $ uploadedCrc = hash ('crc32b ' , $ uploadedContents );
78+
79+ $ this ->assertEquals ($ crc , $ uploadedCrc );
80+ }
81+
5182 public function testConvertWithFileUrl ()
5283 {
5384 $ params = ['File ' => 'https://cdn.convertapi.com/cara/testfiles/document.docx?test=1 ' ];
0 commit comments