useAttachment

useAttachment(
	attachmentName:string,
	itemId:number,
	list:string,
	options?: AttachmentInfoOptions,
	deps?:any[]): IAttachmentInfo | null | undefined;

useAttachment(
	attachmentName:string,
	itemId:number,
	list:string,
	options?: AttachmentTextOptions,
	deps?:any[]): string | null | undefined;

useAttachment(
	attachmentName:string,
	itemId:number,
	list:string,
	options?: AttachmentBlobOptions,
	deps?:any[]): Blob | null | undefined;

useAttachment(
	attachmentName:string,
	itemId:number,
	list:string,
	options?: AttachmentBufferOptions,
	deps?:any[]): ArrayBuffer | null | undefined;

Returns an attachment info or attachment content from item.

Examples

Get attachment info,

const attachmentProps = useAttachment("my-attachment.txt", 12, "My List");

Query attachment info properties,

const attachmentProps = useAttachment("my-attachment.txt", 12, "My List"), {
	query: {
		select: ["Title", "Id"]
	}
});

Get attachment content as Blob,

const contentAsBlob = useAttachment("my-attachment.txt", 12, "My List", {
	type: "blob"
});

Get attachment content as ArrayBuffer,

const contentAsBuffer = useAttachment("my-attachment.txt", 12, "My List", {
	type: "buffer"
});

Get attachment content as string,

const contentAsText = useAttachment("my-attachment.txt", 12, "My List", {
	type: "text"
});

Parameters

NameTypeDescriptionTracked for changes
attachmentNamestringAttachment nameYes
itemIdnumberList item IDYes
liststringTarget list UUID or titleYes
options?AttachmentInfoOptions | AttachmentBlobOptions | AttachmentTextOptions | AttachmentBufferOptionsuseAttachment hook optionsPartially
deps?DependencyListHook dependency list.Yes