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
Name | Type | Description | Tracked for changes |
---|---|---|---|
attachmentName | string | Attachment name | Yes |
itemId | number | List item ID | Yes |
list | string | Target list UUID or title | Yes |
options? | AttachmentInfoOptions | AttachmentBlobOptions | AttachmentTextOptions | AttachmentBufferOptions | useAttachment hook options | Partially |
deps? | DependencyList | Hook dependency list. | Yes |