diff options
Diffstat (limited to 'application/netscape/NetscapeBookmarkUtils.php')
-rw-r--r-- | application/netscape/NetscapeBookmarkUtils.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/application/netscape/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php index 8557cca2..b150f649 100644 --- a/application/netscape/NetscapeBookmarkUtils.php +++ b/application/netscape/NetscapeBookmarkUtils.php | |||
@@ -6,6 +6,7 @@ use DateTime; | |||
6 | use DateTimeZone; | 6 | use DateTimeZone; |
7 | use Exception; | 7 | use Exception; |
8 | use Katzgrau\KLogger\Logger; | 8 | use Katzgrau\KLogger\Logger; |
9 | use Psr\Http\Message\UploadedFileInterface; | ||
9 | use Psr\Log\LogLevel; | 10 | use Psr\Log\LogLevel; |
10 | use Shaarli\Bookmark\Bookmark; | 11 | use Shaarli\Bookmark\Bookmark; |
11 | use Shaarli\Bookmark\BookmarkServiceInterface; | 12 | use Shaarli\Bookmark\BookmarkServiceInterface; |
@@ -79,20 +80,20 @@ class NetscapeBookmarkUtils | |||
79 | /** | 80 | /** |
80 | * Imports Web bookmarks from an uploaded Netscape bookmark dump | 81 | * Imports Web bookmarks from an uploaded Netscape bookmark dump |
81 | * | 82 | * |
82 | * @param array $post Server $_POST parameters | 83 | * @param array $post Server $_POST parameters |
83 | * @param array $files Server $_FILES parameters | 84 | * @param UploadedFileInterface $file File in PSR-7 object format |
84 | * | 85 | * |
85 | * @return string Summary of the bookmark import status | 86 | * @return string Summary of the bookmark import status |
86 | */ | 87 | */ |
87 | public function import($post, $files) | 88 | public function import($post, UploadedFileInterface $file) |
88 | { | 89 | { |
89 | $start = time(); | 90 | $start = time(); |
90 | $filename = $files['filetoupload']['name']; | 91 | $filename = $file->getClientFilename(); |
91 | $filesize = $files['filetoupload']['size']; | 92 | $filesize = $file->getSize(); |
92 | $data = file_get_contents($files['filetoupload']['tmp_name']); | 93 | $data = (string) $file->getStream(); |
93 | 94 | ||
94 | if (preg_match('/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $data) === 0) { | 95 | if (preg_match('/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $data) === 0) { |
95 | return self::importStatus($filename, $filesize); | 96 | return $this->importStatus($filename, $filesize); |
96 | } | 97 | } |
97 | 98 | ||
98 | // Overwrite existing bookmarks? | 99 | // Overwrite existing bookmarks? |