git » sdk » commit 0b9ed70

AttachmentSource: Add haxe implementation

author Matthew Wild
2025-04-15 14:54:25 UTC
committer Matthew Wild
2025-04-15 16:14:45 UTC
parent 70d170f39f4271568fe595d836d7cfcfac6f497f

AttachmentSource: Add haxe implementation

snikket/AttachmentSource.hx +19 -0

diff --git a/snikket/AttachmentSource.hx b/snikket/AttachmentSource.hx
index e69de29..d0da87a 100644
--- a/snikket/AttachmentSource.hx
+++ b/snikket/AttachmentSource.hx
@@ -0,0 +1,19 @@
+package snikket;
+
+class AttachmentSource {
+	public final path: String;
+	public final type: String;
+	public final name: String;
+	public final size: Int;
+
+	public function new(path: String, mime: String) {
+		this.name = haxe.io.Path.withoutDirectory(path);
+		this.path = sys.FileSystem.fullPath(path);
+		this.size = sys.FileSystem.stat(this.path).size;
+		this.type = mime;
+	}
+
+	public inline function tinkSource() {
+		return tink.io.Source.ofInput(this.name, sys.io.File.read(path));
+	}
+}