livephoto: allow access for folder shares
parent
6d508890c4
commit
874258dae9
|
@ -95,28 +95,22 @@ class VideoController extends ApiBase
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
|
* @PublicPage
|
||||||
|
*
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* Return the live video part of a live photo
|
* Return the live video part of a live photo
|
||||||
*/
|
*/
|
||||||
public function livephoto(
|
public function livephoto(
|
||||||
string $fileid,
|
int $fileid,
|
||||||
string $etag = '',
|
|
||||||
string $liveid = '',
|
string $liveid = '',
|
||||||
string $format = '',
|
string $format = '',
|
||||||
string $transcode = ''
|
string $transcode = ''
|
||||||
) {
|
) {
|
||||||
$fileid = (int) $fileid;
|
$file = $this->getUserFile($fileid);
|
||||||
$files = $this->rootFolder->getById($fileid);
|
if (null === $file) {
|
||||||
if (0 === \count($files)) {
|
|
||||||
return new JSONResponse(['message' => 'File not found'], Http::STATUS_NOT_FOUND);
|
return new JSONResponse(['message' => 'File not found'], Http::STATUS_NOT_FOUND);
|
||||||
}
|
}
|
||||||
$file = $files[0];
|
|
||||||
|
|
||||||
// Check file etag
|
|
||||||
if ($etag !== $file->getEtag()) {
|
|
||||||
return new JSONResponse(['message' => 'File changed'], Http::STATUS_PRECONDITION_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check file liveid
|
// Check file liveid
|
||||||
if (!$liveid) {
|
if (!$liveid) {
|
||||||
|
|
|
@ -141,20 +141,23 @@ const getPreviewUrl = function (
|
||||||
size: number | [number, number]
|
size: number | [number, number]
|
||||||
) {
|
) {
|
||||||
const [x, y] = typeof size === "number" ? [size, size] : size;
|
const [x, y] = typeof size === "number" ? [size, size] : size;
|
||||||
const a = square ? "0" : "1";
|
|
||||||
|
|
||||||
// Get base URL
|
// Get base URL
|
||||||
let url = generateUrl(
|
const url = generateUrl(`/apps/memories/api/image/preview/${photo.fileid}`);
|
||||||
`/apps/memories/api/image/preview/${photo.fileid}?c=${photo.etag}&x=${x}&y=${y}&a=${a}`
|
|
||||||
);
|
// Build query
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
query.set("c", photo.etag);
|
||||||
|
query.set("x", x.toString());
|
||||||
|
query.set("y", y.toString());
|
||||||
|
query.set("a", square ? "0" : "1");
|
||||||
|
|
||||||
// Public preview
|
// Public preview
|
||||||
if (vuerouter.currentRoute.name === "folder-share") {
|
if (vuerouter.currentRoute.name === "folder-share") {
|
||||||
const token = vuerouter.currentRoute.params.token;
|
query.set("folder_share", vuerouter.currentRoute.params.token);
|
||||||
url += `&folder_share=${token}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url + "?" + query.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -241,11 +241,25 @@ export function getFolderRoutePath(basePath: string) {
|
||||||
* Get URL to live photo video part
|
* Get URL to live photo video part
|
||||||
*/
|
*/
|
||||||
export function getLivePhotoVideoUrl(p: IPhoto, transcode: boolean) {
|
export function getLivePhotoVideoUrl(p: IPhoto, transcode: boolean) {
|
||||||
let url = generateUrl(
|
// Get base url
|
||||||
`/apps/memories/api/video/livephoto/${p.fileid}?etag=${p.etag}&liveid=${p.liveid}`
|
const url = generateUrl(`/apps/memories/api/video/livephoto/${p.fileid}`);
|
||||||
);
|
|
||||||
if (transcode) url += `&transcode=${videoClientIdPersistent}`;
|
// Build query string
|
||||||
return url;
|
const query = new URLSearchParams();
|
||||||
|
query.set("etag", p.etag);
|
||||||
|
query.set("liveid", p.liveid);
|
||||||
|
|
||||||
|
// Transcode if allowed
|
||||||
|
if (transcode) {
|
||||||
|
query.set("transcode", videoClientIdPersistent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add auth token for public share
|
||||||
|
if (vuerouter.currentRoute.name === "folder-share") {
|
||||||
|
query.set("folder_share", vuerouter.currentRoute.params.token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return url + "?" + query.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue