Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): preview document attachments in the file viewer #9292

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/9292/headmerged by juliusmarminge View on GitHub

Showing 16 changed files with 100 additions and 6 deletions (loading 13).

x
0 of 16 viewed, 16 left
61 additions and 0 deletionsapps/server/src/assets/AssetAccess.test.tsModified
View file
@@ -576,6 +576,67 @@
});
}).pipe(Effect.provide(testLayer)),
+​
+ it.effect("serves document attachments inline when a viewer requests it", () =>
+ Effect.gen(function* () {
+ const config = yield* ServerConfig.ServerConfig;
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const attachmentId = "thread-1-00000000-0000-4000-8000-000000000001-pdf";
+ const attachmentPath = path.join(config.attachmentsDir, `${attachmentId}.pdf`);
+ yield* fileSystem.makeDirectory(config.attachmentsDir, { recursive: true });
+ yield* fileSystem.writeFile(attachmentPath, new Uint8Array([1, 2, 3]));
+​
+ const result = yield* issueAssetUrl({
+ resource: {
+ _tag: "attachment",
+ attachmentId,
+ fileName: "report.pdf",
+ mimeType: "application/pdf",
+ disposition: "inline",
+ },
+ });
+ const suffix = result.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);
+ const separatorIndex = suffix.indexOf("/");
+​
+ expect(
+ yield* resolveAsset(suffix.slice(0, separatorIndex), suffix.slice(separatorIndex + 1)),
+ ).toEqual({