Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F4637568
file.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
file.ts
View Options
import
{
Field
,
Context
,
File
}
from
"../../../main"
;
import
{
FileDBEntry
}
from
"../../../data-structures/file"
;
type
FileOutput
=
string
|
File
;
type
FileFormat
=
"internal"
|
"url"
;
export
type
FileStorageFormat
=
FileDBEntry
;
export
abstract
class
FileStorage
extends
Field
{
handles_large_data
=
true
;
get_default_file
:
(
context
:
Context
)
=>
Promise
<
File
>
;
async
isProperValue
(
context
:
Context
,
value
:
File
)
{
if
(
typeof
value
===
"string"
)
{
return
Field
.
valid
();
}
if
(
value
===
null
||
value
instanceof
File
)
{
return
Field
.
valid
();
}
return
Field
.
invalid
(
context
.
app
.
i18n
(
"invalid_file_storage"
));
}
setParams
(
params
:
{
get_default_file
:
(
context
:
Context
)
=>
Promise
<
File
>
;
})
{
this
.
get_default_file
=
params
.
get_default_file
;
}
async
encode
(
_
:
Context
,
file
:
File
)
{
if
(
file
===
null
)
{
return
null
;
}
await
file
.
save
();
return
file
.
toDBEntry
();
}
}
/** Takes a {@File} instance as input, stores it in the FS and then decodes to a URL.
*
* **Params**:
* - `get_default_file` - ()=>Promise<{@link File}> - if no file is provided, then this file will be used in it's stead
*/
export
default
class
FileField
extends
FileStorage
{
typeName
=
"file"
;
async
decode
(
_
:
Context
,
db_value
:
FileStorageFormat
|
null
,
__
:
any
)
{
if
(
db_value
===
null
)
{
return
null
;
}
const
file
=
await
File
.
fromID
(
this
.
app
,
db_value
.
id
);
return
file
.
getURL
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, May 27, 23:48 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
662315
Default Alt Text
file.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment