path; $imageContent = file_get_contents($path); $imageName = basename($this->path); $headers = [ "Accept" => "application/json", "x-api-key" => config("immich.key"), ]; $deviceId = "Laravel"; $albumId = "6ae6dda5-1681-4cf5-9ebe-d0038c9308a8"; $id = "503832b6-afa0-4dca-8fca-a7df89c8f658"; $url = config("immich.url"); $res = Http::withHeaders($headers) ->attach("assetData", $imageContent, $imageName) ->post("$url/api/assets", [ "deviceAssetId" => $id, "deviceId" => $deviceId, "fileCreatedAt" => now()->format("Y-m-d H:i:s"), "fileModifiedAt" => now()->format("Y-m-d H:i:s"), ]); $response = $res->json(); if (isset($response["status"])) { $content = $res->json(); if ($response["status"] === "duplicate") { throw new Exception( "duplicate image : " . $response["id"], 0, ); } Http::withHeaders($headers)->put( "$url/api/albums/$albumId/assets", [ "ids" => [$content["id"]], ], ); } } catch (Exception $e) { Log::error($e->getMessage(), ["path" => $this->path]); } return 0; } }