{"action":"created","issue":{"url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/368","repository_url":"https://api.github.com/repos/spatie/laravel-medialibrary","labels_url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/368/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/368/comments","events_url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/368/events","html_url":"https://github.com/spatie/laravel-medialibrary/issues/368","id":181922590,"number":368,"title":"Uploads to wrong directory","user":{"login":"timgavin","id":1012049,"avatar_url":"https://avatars.githubusercontent.com/u/1012049?v=3","gravatar_id":"","url":"https://api.github.com/users/timgavin","html_url":"https://github.com/timgavin","followers_url":"https://api.github.com/users/timgavin/followers","following_url":"https://api.github.com/users/timgavin/following{/other_user}","gists_url":"https://api.github.com/users/timgavin/gists{/gist_id}","starred_url":"https://api.github.com/users/timgavin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgavin/subscriptions","organizations_url":"https://api.github.com/users/timgavin/orgs","repos_url":"https://api.github.com/users/timgavin/repos","events_url":"https://api.github.com/users/timgavin/events{/privacy}","received_events_url":"https://api.github.com/users/timgavin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-10T00:36:41Z","updated_at":"2016-10-10T09:14:51Z","closed_at":null,"body":"@nicolasbeauvais I thought I'd open this up to ask a question about the code you posted in [#365](https://github.com/spatie/laravel-medialibrary/issues/365).\r\n\r\n```\r\n$post->addMedia($request->file('file'))\r\n     ->usingFileName(str_random(16).'.'.$request->file('file')->getClientOriginalExtension())\r\n     ->toCollection('video');\r\n```\r\n\r\nI've been having too many issues with the Media Library when trying to upload, and it could be because I just don't understand it well enough.\r\n\r\nI want to add the video to the medial library, unfortunately, every time I do the video is uploaded into the `media` directory instead of the `uploads` directory.\r\n\r\n#### config/laravel-medialibrary.php\r\n```\r\n'defaultFilesystem' => 'media'\r\n```\r\n\r\n#### config.filesystem.php\r\n```\r\n'media' => [\r\n    'driver' => 'local',\r\n    'root' => storage_path('app/media'),\r\n],\r\n\r\n'video' => [\r\n    'driver' => 'local',\r\n    'root' => storage_path('app/uploads'),\r\n],\r\n```\r\n\r\nNo matter what I do, the file is uploaded into `media` instead of `uploads`. I need it to go into `uploads` so that I can keep track of it.\r\n\r\nOr is there any way to just add the info to the `media` table without having the pass the file? Some way of manually adding the filename, collection name, etc?"},"comment":{"url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/comments/252568556","html_url":"https://github.com/spatie/laravel-medialibrary/issues/368#issuecomment-252568556","issue_url":"https://api.github.com/repos/spatie/laravel-medialibrary/issues/368","id":252568556,"user":{"login":"nicolasbeauvais","id":2951704,"avatar_url":"https://avatars.githubusercontent.com/u/2951704?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolasbeauvais","html_url":"https://github.com/nicolasbeauvais","followers_url":"https://api.github.com/users/nicolasbeauvais/followers","following_url":"https://api.github.com/users/nicolasbeauvais/following{/other_user}","gists_url":"https://api.github.com/users/nicolasbeauvais/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolasbeauvais/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolasbeauvais/subscriptions","organizations_url":"https://api.github.com/users/nicolasbeauvais/orgs","repos_url":"https://api.github.com/users/nicolasbeauvais/repos","events_url":"https://api.github.com/users/nicolasbeauvais/events{/privacy}","received_events_url":"https://api.github.com/users/nicolasbeauvais/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T09:14:51Z","updated_at":"2016-10-10T09:14:51Z","body":"Collections and media disks are two different things.\r\n\r\nmedialibrary collections are used like \"categories\" of files and are abstracted of the disks where they are stored.\r\n\r\nFor example, I have a User entity, my users can have one avatar and a photo gallery of their last holidays. I want all files stored on the default media disk.\r\n\r\n```php\r\n// Add the user avatar\r\n$user->addMedia($request->file('avatar'))->toCollection('avatar');\r\n\r\n// Add the user gallery images\r\nforeach ($request->file('galery_files') as $key => $file) {\r\n    $user->addMedia($file)->toCollection('gallery');\r\n}\r\n```\r\n\r\nNow the media attached to my user are separated in 2 different collections so I can easily query my user avatar or only the media in its gallery or both.\r\n\r\nMedialibrary use a default disk to store all the files, but you can pass the second parameter to `toCollection` to store a specific file on a different disk, let's say I want my avatar in the uploads directory but not my galleries I just have to do:\r\n\r\n```php\r\n// Will store the file with the avatar collection but on the video disk.\r\n$user->addMedia($request->file('avatar'))->toCollection('avatar', 'video');\r\n```"}}
{"actor":{"display_login":"nicolasbeauvais"}}