offsite 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/server/dist/main.mjs +10 -1
- package/apps/server/dist/main.mjs.map +1 -1
- package/apps/web/dist/assets/{dist-Cq4WVWnm.js → dist-BtDwoA_O.js} +1 -1
- package/apps/web/dist/assets/{index-DFIcVxTR.js → index-B9Y6tnXx.js} +28 -28
- package/apps/web/dist/index.html +1 -1
- package/apps/web/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -4515,11 +4515,18 @@ function linkProjectMedia(cwd, file) {
|
|
|
4515
4515
|
const full = resolveProjectFile(cwd, file);
|
|
4516
4516
|
const mediaType = mediaTypes.get(path.extname(full).toLowerCase());
|
|
4517
4517
|
if (mediaType === void 0) throw new Error(`${file} is not an image, video or audio file`);
|
|
4518
|
+
return addLink(full, mediaType, null);
|
|
4519
|
+
}
|
|
4520
|
+
function linkProjectDownload(cwd, file) {
|
|
4521
|
+
return addLink(resolveProjectFile(cwd, file), "application/octet-stream", path.basename(file));
|
|
4522
|
+
}
|
|
4523
|
+
function addLink(file, mediaType, download) {
|
|
4518
4524
|
for (const [token, link] of mediaLinks) if (link.expiresAt <= Date.now()) mediaLinks.delete(token);
|
|
4519
4525
|
const token = randomBytes(32).toString("base64url");
|
|
4520
4526
|
mediaLinks.set(token, {
|
|
4521
|
-
file
|
|
4527
|
+
file,
|
|
4522
4528
|
mediaType,
|
|
4529
|
+
download,
|
|
4523
4530
|
expiresAt: Date.now() + MEDIA_LINK_LIFETIME
|
|
4524
4531
|
});
|
|
4525
4532
|
return token;
|
|
@@ -6162,6 +6169,7 @@ const handlers = {
|
|
|
6162
6169
|
"files.list": (params) => listFiles(projectPath(params.projectId)),
|
|
6163
6170
|
"files.read": (params) => readProjectFile(projectPath(params.projectId), params.path),
|
|
6164
6171
|
"files.media": (params) => linkProjectMedia(projectPath(params.projectId), params.path),
|
|
6172
|
+
"files.download": (params) => linkProjectDownload(projectPath(params.projectId), params.path),
|
|
6165
6173
|
"files.upload": (params) => saveUpload(params.name, Buffer.from(params.data, "base64")),
|
|
6166
6174
|
"tasks.output": (params) => taskOutput(params.sessionId, params.path),
|
|
6167
6175
|
"git.status": (params) => gitRepos(projectPath(params.projectId)),
|
|
@@ -6467,6 +6475,7 @@ function serveMedia(token, request, response) {
|
|
|
6467
6475
|
return;
|
|
6468
6476
|
}
|
|
6469
6477
|
response.setHeader("content-type", link.mediaType);
|
|
6478
|
+
if (link.download !== null) response.setHeader("content-disposition", `attachment; filename*=UTF-8''${encodeURIComponent(link.download)}`);
|
|
6470
6479
|
response.setHeader("accept-ranges", "bytes");
|
|
6471
6480
|
response.setHeader("cache-control", "private, max-age=3600");
|
|
6472
6481
|
response.setHeader("content-security-policy", "sandbox");
|