Commit 71d7bced authored by Yechang's avatar Yechang
Browse files

feat: change cdn

parent ccf3c339
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
import type { FileClient } from './client.interface';
import qiniu from 'qiniu';
import moment from 'moment';
import _ from 'lodash';

export class QiniuFileClient implements FileClient {
	private bucket = 'spaces';
@@ -12,7 +11,7 @@ export class QiniuFileClient implements FileClient {

	async stat(key: string): Promise<{ size: number } | { error: string }> {
		const bucketManager = new qiniu.rs.BucketManager();
		return new Promise((res, rej) => {
		return new Promise((res) => {
			bucketManager.stat(this.bucket, key, (err, respBody, respInfo) => {
				if (err) {
					res({ error: err.name });
@@ -29,7 +28,7 @@ export class QiniuFileClient implements FileClient {

	async signDownloadLink(key: string): Promise<string> {
		const bucketManager = new qiniu.rs.BucketManager();
		const privateBucketDomain = 'https://file.spaces.sustech.cloud';
		const privateBucketDomain = 'https://cdn.lms.sustech.cloud';
		const deadline = moment().add({ days: 1 }).unix();
		const privateDownloadUrl = bucketManager.privateDownloadUrl(privateBucketDomain, key, deadline);
		return privateDownloadUrl;