protected function create($request, $response, $args)
 {
     $data = $request->getParsedBody();
     $uri = $request->getUri();
     $files = $request->getUploadedFiles();
     array_walk_recursive($files, function ($v, $k) use($files) {
         if ($v instanceof UploadedFile) {
             $files[] = $v;
         }
     });
     $collection = new Collection();
     foreach ($files as $file) {
         if ($file->getError() === UPLOAD_ERR_OK) {
             $f = File::create(['name' => ucfirst($file->getClientFilename()), 'filename' => $file->getClientFilename(), 'filetype' => $file->getClientMediaType(), 'filesize' => $file->getSize(), 'url' => $uri->getScheme() . '://' . $uri->getHost() . '/media/' . $file->getClientFilename(), 'download' => false]);
             $collection->push($f);
             $file->moveTo($this->settings['mediaDir'] . $file->getClientFilename());
         }
     }
     return $response->write($collection->toJson());
 }
 /**
  * Get the collection of items as JSON.
  *
  * @param  int $options
  * @return string
  */
 public function toJson($options = 0)
 {
     return parent::toJson(JSON_FORCE_OBJECT);
 }