forked from DebaucheryLibrarian/traxxx
Not using media hash subdirs for S3 uploads. Updated video player for S3.
This commit is contained in:
parent
e9603ecec9
commit
c1829c64c2
|
@ -7,7 +7,7 @@
|
||||||
@pause="$emit('pause')"
|
@pause="$emit('pause')"
|
||||||
>
|
>
|
||||||
<source
|
<source
|
||||||
:src="`/media/${video.path}`"
|
:src="getPath(video)"
|
||||||
type="video/mp4"
|
type="video/mp4"
|
||||||
>
|
>
|
||||||
</video>
|
</video>
|
||||||
|
|
|
@ -44,7 +44,7 @@ $breakpoint4: 1500px;
|
||||||
--text-contrast: #fff;
|
--text-contrast: #fff;
|
||||||
|
|
||||||
--background: var(--background-light);
|
--background: var(--background-light);
|
||||||
--background-dim: #fafafa;
|
--background-dim: #f5f5f5;
|
||||||
--background-soft: #fdfdfd;
|
--background-soft: #fdfdfd;
|
||||||
|
|
||||||
--profile: #222;
|
--profile: #222;
|
||||||
|
|
15
src/media.js
15
src/media.js
|
@ -328,6 +328,8 @@ async function storeS3Object(filepath, media) {
|
||||||
|
|
||||||
await fsPromises.unlink(fullFilepath);
|
await fsPromises.unlink(fullFilepath);
|
||||||
|
|
||||||
|
logger.silly(`Uploaded '${media.id}' from ${media.src} to S3 bucket '${status.Bucket}' at ${status.Location}`);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,10 +373,10 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil
|
||||||
logger.silly(`Storing permanent media files for ${media.id} from ${media.src} at ${filepath}`);
|
logger.silly(`Storing permanent media files for ${media.id} from ${media.src} at ${filepath}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const thumbdir = path.join(media.role, 'thumbs', hashDir, hashSubDir);
|
const thumbdir = config.s3.enabled ? path.join(media.role, 'thumbs') : path.join(media.role, 'thumbs', hashDir, hashSubDir);
|
||||||
const thumbpath = path.join(thumbdir, filename);
|
const thumbpath = path.join(thumbdir, filename);
|
||||||
|
|
||||||
const lazydir = path.join(media.role, 'lazy', hashDir, hashSubDir);
|
const lazydir = config.s3.enabled ? path.join(media.role, 'lazy') : path.join(media.role, 'lazy', hashDir, hashSubDir);
|
||||||
const lazypath = path.join(lazydir, filename);
|
const lazypath = path.join(lazydir, filename);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -459,13 +461,13 @@ async function storeFile(media, options) {
|
||||||
try {
|
try {
|
||||||
const hashDir = media.meta.hash.slice(0, 2);
|
const hashDir = media.meta.hash.slice(0, 2);
|
||||||
const hashSubDir = media.meta.hash.slice(2, 4);
|
const hashSubDir = media.meta.hash.slice(2, 4);
|
||||||
const hashFilename = media.meta.hash.slice(4);
|
const hashFilename = config.s3.enabled ? media.meta.hash : media.meta.hash.slice(4);
|
||||||
|
|
||||||
const filename = media.quality
|
const filename = media.quality
|
||||||
? `${hashFilename}_${media.quality}.${media.meta.extension}`
|
? `${hashFilename}_${media.quality}.${media.meta.extension}`
|
||||||
: `${hashFilename}.${media.meta.extension}`;
|
: `${hashFilename}.${media.meta.extension}`;
|
||||||
|
|
||||||
const filedir = path.join(media.role, hashDir, hashSubDir);
|
const filedir = config.s3.enabled ? media.role : path.join(media.role, hashDir, hashSubDir);
|
||||||
const filepath = path.join(filedir, filename);
|
const filepath = path.join(filedir, filename);
|
||||||
|
|
||||||
if (argv.force) {
|
if (argv.force) {
|
||||||
|
@ -493,6 +495,11 @@ async function storeFile(media, options) {
|
||||||
// move temp file to permanent location
|
// move temp file to permanent location
|
||||||
await fsPromises.rename(media.file.path, path.join(config.media.path, filepath));
|
await fsPromises.rename(media.file.path, path.join(config.media.path, filepath));
|
||||||
|
|
||||||
|
if (config.s3.enabled) {
|
||||||
|
// upload the file to S3 storage, will remove original
|
||||||
|
await storeS3Object(filepath, media);
|
||||||
|
}
|
||||||
|
|
||||||
logger.silly(`Stored permanent media file for ${media.id} from ${media.src} at ${filepath}`);
|
logger.silly(`Stored permanent media file for ${media.id} from ${media.src} at ${filepath}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue