Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
805be1c8f1 | ||
|
|
eaf13edfe8 | ||
|
|
9ce010f5c1 |
No files matched your search
+8
-2
@@ -197,7 +197,13 @@ $redirectUrlUtm = $redirect_url_utm ?? '';
|
|||||||
function uploadFile(file) {
|
function uploadFile(file) {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
// Ключ загрузки: по нему сайт передаёт её в сессию посетителя (/api/images/public/claim, годен 30 мин).
|
||||||
|
// randomUUID есть в HTTPS-контексте; где его нет (старый Safari), есть getRandomValues.
|
||||||
|
const clientKey = crypto.randomUUID
|
||||||
|
? crypto.randomUUID()
|
||||||
|
: Array.from(crypto.getRandomValues(new Uint8Array(16)), (b) => b.toString(16).padStart(2, '0')).join('');
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
formData.append('client_key', clientKey);
|
||||||
|
|
||||||
const actionUrl = createApiUrl || formEl.getAttribute('action') || '/api/images/public/create';
|
const actionUrl = createApiUrl || formEl.getAttribute('action') || '/api/images/public/create';
|
||||||
xhr.open('POST', actionUrl, true);
|
xhr.open('POST', actionUrl, true);
|
||||||
@@ -232,8 +238,8 @@ $redirectUrlUtm = $redirect_url_utm ?? '';
|
|||||||
process.setStage(1);
|
process.setStage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build redirect target URL: $redirect_url_base . $imageId . ($redirect_url_utm ? '&' . $redirect_url_utm : '')
|
// Переход: $redirect_url_base . client_key . ($redirect_url_utm ? '&' . $redirect_url_utm : '')
|
||||||
let targetUrl = redirectUrlBase + encodeURIComponent(imageId);
|
let targetUrl = redirectUrlBase + encodeURIComponent(clientKey);
|
||||||
if (redirectUrlUtm) {
|
if (redirectUrlUtm) {
|
||||||
// const sep = targetUrl.includes('?') ? '&' : '?';
|
// const sep = targetUrl.includes('?') ? '&' : '?';
|
||||||
targetUrl += '&' + redirectUrlUtm;
|
targetUrl += '&' + redirectUrlUtm;
|
||||||
|
|||||||
@@ -71,8 +71,11 @@ $UTM = $get_params;
|
|||||||
$host = $config['host'] ?? ($_SERVER['HTTP_HOST'] ?? '');
|
$host = $config['host'] ?? ($_SERVER['HTTP_HOST'] ?? '');
|
||||||
$apiHost = $host ? (preg_match('#^https?://#', $host) ? rtrim($host, '/') : 'https://' . rtrim($host, '/')) : '';
|
$apiHost = $host ? (preg_match('#^https?://#', $host) ? rtrim($host, '/') : 'https://' . rtrim($host, '/')) : '';
|
||||||
|
|
||||||
$redirect_url_base = ($apiHost ? $apiHost : '') . '/public/upscale?id=';
|
// После загрузки — на сайт по ключу загрузки (client_key): /api/images/public/claim кладёт её в сессию посетителя и ведёт
|
||||||
$redirect_url_utm = http_build_query($get_params);
|
// на /public/upscale. Сразу на /public/upscale нельзя: сессия кросс-доменной загрузки посетителю на сайте недоступна — 404.
|
||||||
|
$redirect_url_base = ($apiHost ? $apiHost : '') . '/api/images/public/claim?key=';
|
||||||
|
// свою метку key — нет: её значение перебило бы ключ загрузки в адресе claim
|
||||||
|
$redirect_url_utm = http_build_query(array_diff_key($get_params, ['key' => true]));
|
||||||
|
|
||||||
$assetsUriPrefix = $config['assetsUriPrefix'] ?? '';
|
$assetsUriPrefix = $config['assetsUriPrefix'] ?? '';
|
||||||
if ($assetsUriPrefix === '' && !is_dir(__DIR__ . '/images') && !empty($apiHost)) {
|
if ($assetsUriPrefix === '' && !is_dir(__DIR__ . '/images') && !empty($apiHost)) {
|
||||||
|
|||||||
Reference in new issue
Block a user