Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996589
attachment-assigner.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
attachment-assigner.ts
View Options
import
App
from
"../../app/app"
;
import
Context
from
"../../context"
;
import
*
as
Errors
from
"../../response/errors"
;
import
Collection
from
"../../chip-types/collection"
;
import
{
AttachmentParams
,
AssignAttachmentsResult
}
from
"../types"
;
export
default
async
function
(
app
:
App
,
context
:
Context
,
params
:
AttachmentParams
,
root_collection
:
Collection
,
documents
:
Array
<
any
>
)
:
Promise
<
AssignAttachmentsResult
>
{
const
attachments_query
=
params
.
attachments
;
const
attachments
=
{};
const
fieldsWithAttachments
=
{};
for
(
let
field_name
of
Object
.
keys
(
attachments_query
))
{
const
field
=
root_collection
.
fields
[
field_name
];
if
(
!
field
)
{
throw
new
Errors
.
NotFound
(
`Given field
${
field_name
}
is not declared in collection!`
);
}
const
loader
=
await
field
.
get_attachment_loader
(
context
,
field_name
,
{
...
field
.
params
,
attachments_query
:
attachments_query
[
field_name
],
documents
,
});
if
(
!
loader
)
{
throw
new
Errors
.
FieldDoesNotSupportAttachments
(
`Given field
${
field_name
}
does not support attachments!`
);
}
await
loader
.
loadTo
(
app
,
attachments
,
fieldsWithAttachments
);
}
return
{
attachments
,
fieldsWithAttachments
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:05 (21 m, 10 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557329
Default Alt Text
attachment-assigner.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment