Skip to content

Commit

Permalink
✔ Chunk :: Kembali Ke Semula ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Jan 9, 2024
1 parent 02418d3 commit 681ada5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class MailWebhookController {
{
dest: environment.uploadFolder,
limits: {
fileSize: CONSTANTS.fileSizeAttachmentChunkCloudflareLimit // Default Max Email 25 MB
fileSize: 25 * 1000 * 1000 // Default Max Email 25 MB
}
}
)
Expand Down
14 changes: 1 addition & 13 deletions projects/main-site/src/api/services/discord.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,7 @@ export class DiscordService {
async sendAttachment(attachment: AttachmentModel, user: UserModel = null, chunkIdx = null): Promise<string> {
let currentChunkIdx: number = 0;
let chunkParent: string = attachment?.discord;
let chunkSize = CONSTANTS.fileSizeAttachmentChunkDiscordLimit;
// Fore Re-Fresh `.fetch()`
const botGuild = this.bot ? await this.bot.guilds.fetch(environment.discord.guild_id) : null;
if (botGuild) {
const totalBoosts = botGuild.premiumSubscriptionCount;
if (totalBoosts >= 14) {
chunkSize = 100 * 1000 * 1000; // Level 3
} else if (totalBoosts >= 7) {
chunkSize = 50 * 1000 * 1000; // Level 2
} else {
chunkSize = CONSTANTS.fileSizeAttachmentChunkDiscordLimit;
}
}
let chunkSize = CONSTANTS.fileSizeAttachmentChunkLimit;
const crs = createReadStream(
`${environment.uploadFolder}/${attachment.name}`,
{
Expand Down
6 changes: 3 additions & 3 deletions projects/main-site/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ import { environment } from '../environments/app/environment';
),
UploadxModule.withConfig({
autoUpload: false,
concurrency: 1,
concurrency: 2,
endpoint: `${environment.apiUrl}/attachment`,
headers: {
'ngsw-bypass': 'true'
},
retryConfig: {
maxAttempts: 3
maxAttempts: 8
},
maxChunkSize: CONSTANTS.fileSizeAttachmentChunkCloudflareLimit
maxChunkSize: CONSTANTS.fileSizeAttachmentChunkLimit
})
],
providers: [
Expand Down
3 changes: 1 addition & 2 deletions projects/main-site/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export const CONSTANTS = {
'application/x-zip',
'application/x-zip-compressed'
],
fileSizeAttachmentChunkCloudflareLimit: 32 * 1000 * 1000, // Cloudflare User Plan -- Free Is 100 MB ~ T.T
fileSizeAttachmentChunkDiscordLimit: 8 * 1000 * 1000, // Discord -- Without Nitro Is 8 MB ~ T.T
fileSizeAttachmentChunkLimit: 8 * 1000 * 1000, // Cloudflare User Plan -- Free Is 100 MB ~ T.T
fileTypeAttachmentStreamable: [
'mkv',
'mp4'
Expand Down

0 comments on commit 681ada5

Please sign in to comment.