Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import DropboxOauthPanel from "./components/DropboxOauthPanel";
const DROPBOX_AUTH_DOMAIN = "https://roamjs.com";
const DROPBOX_UPLOAD_URL = "https://content.dropboxapi.com/2/files/upload";
const DROPBOX_LOADING_TEXT = "";
const DROPBOX_UPLOAD_LIMIT_MB = 150;
const DROPBOX_UPLOAD_LIMIT_BYTES = DROPBOX_UPLOAD_LIMIT_MB * 1024 * 1024;
Comment on lines +22 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Upload limit uses binary MiB instead of decimal MB

The limit is calculated as 150 * 1024 * 1024 (157,286,400 bytes) at src/index.ts:23, but the Dropbox /2/files/upload API documents its limit as 150 MB. If Dropbox means decimal megabytes (150,000,000 bytes), files between ~150 MB and ~157 MB would pass the client-side check but still fail server-side. Since the server error path already handles failures gracefully (catchError at src/index.ts:289), the impact is limited to a less-helpful error message for that narrow range. Worth confirming against Dropbox's actual byte threshold.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


const mimeLookup = (path: string) => {
if (!path || typeof path !== "string") {
Expand Down Expand Up @@ -268,6 +270,20 @@ export default runExtension(async (args) => {
e.stopImmediatePropagation();
e.preventDefault();

if (fileToUpload.size > DROPBOX_UPLOAD_LIMIT_BYTES) {
const fileName = fileToUpload.name || "This file";
renderToast({
id: "dropbox-upload-too-large",
intent: Intent.DANGER,
timeout: 8000,
content:
`${fileName} is too large to upload to Dropbox. ` +
`This uploader currently supports files up to ${DROPBOX_UPLOAD_LIMIT_MB} MB.`,
});
hideDropBars();
return;
}

getLoadingUid().then((uid) => {
const removeLoading = renderUploadLoading(uid);
const catchError = (e: unknown) => {
Expand Down
Loading