Images can now be uploaded via the media endpoint in a basic way
This commit is contained in:
parent
16015d3f4b
commit
764557b96b
10 changed files with 125 additions and 75 deletions
|
@ -2,15 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Media;
|
||||
use App\Place;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\NoteService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\PlaceService;
|
||||
use App\Services\TokenService;
|
||||
use App\{Media, Place};
|
||||
use Illuminate\Http\{Request, Response};
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
use App\Services\{NoteService, PlaceService, TokenService};
|
||||
|
||||
class MicropubController extends Controller
|
||||
{
|
||||
|
@ -98,6 +96,18 @@ class MicropubController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
$data['photo'] = [];
|
||||
Log::info('Checking request for photos');
|
||||
Log::info($request->all());
|
||||
if (is_array($request->input('photo'))) {
|
||||
foreach ($request->input('photo') as $photo) {
|
||||
if (is_string($photo)) {
|
||||
Log::info($photo);
|
||||
//only supporting media URLs for now
|
||||
$data['photo'][] = $photo;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
$note = $this->noteService->createNote($data);
|
||||
} catch (Exception $exception) {
|
||||
|
@ -185,6 +195,15 @@ class MicropubController extends Controller
|
|||
'syndicate-to' => config('syndication.targets'),
|
||||
]);
|
||||
}
|
||||
|
||||
//nope, how about a config query?
|
||||
if ($request->input('q') == 'config') {
|
||||
return response()->json([
|
||||
'syndicate-to' => config('syndication.targets'),
|
||||
'media-endpoint' => route('media-endpoint'),
|
||||
]);
|
||||
}
|
||||
|
||||
//nope, how about a geo URL?
|
||||
if (substr($request->input('q'), 0, 4) === 'geo:') {
|
||||
preg_match_all(
|
||||
|
@ -203,13 +222,6 @@ class MicropubController extends Controller
|
|||
'places' => $places,
|
||||
]);
|
||||
}
|
||||
//nope, how about a config query?
|
||||
if ($request->input('q') == 'config') {
|
||||
return response()->json([
|
||||
'syndicate-to' => config('syndication.targets'),
|
||||
'media-endpoint' => route('media-endpoint'),
|
||||
]);
|
||||
}
|
||||
|
||||
//nope, just return the token
|
||||
return response()->json([
|
||||
|
@ -256,7 +268,7 @@ class MicropubController extends Controller
|
|||
$scopes = explode(' ', $tokenData->getClaim('scope'));
|
||||
if (array_search('post', $scopes) !== false) {
|
||||
//check media valid
|
||||
if ($request->file('file')->isValid()) {
|
||||
if ($request->hasFile('file') && $request->file('file')->isValid()) {
|
||||
//save media
|
||||
try {
|
||||
$filename = Uuid::uuid4() . '.' . $request->file('file')->extension();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue