Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
a96f94b6
Commit
a96f94b6
authored
2 years ago
by
Michal Malý
Browse files
Options
Downloads
Patches
Plain Diff
Allow download of Gzipped files
parent
ebdfc694
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
src/mol-plugin-state/actions/file.ts
+13
-7
13 additions, 7 deletions
src/mol-plugin-state/actions/file.ts
with
14 additions
and
7 deletions
CHANGELOG.md
+
1
−
0
View file @
a96f94b6
...
...
@@ -11,6 +11,7 @@ Note that since we don't clearly distinguish between a public and private interf
-
Improve naming of some internal types in Confal pyramids extension coordinate
-
Add example mmCIF file with categories necessary to display Confal pyramids
-
Change the lookup logic of NtC steps from residues
-
Add support for download of gzipped files
## [v3.13.0] - 2022-07-24
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin-state/actions/file.ts
+
13
−
7
View file @
a96f94b6
...
...
@@ -83,7 +83,7 @@ export const DownloadFile = StateAction.build({
display
:
{
name
:
'
Download File
'
,
description
:
'
Load one or more file from an URL
'
},
from
:
PluginStateObject
.
Root
,
params
:
(
a
,
ctx
:
PluginContext
)
=>
{
const
options
=
[...
ctx
.
dataFormats
.
options
,
[
'
zip
'
,
'
Zip
'
]
as const
];
const
options
=
[...
ctx
.
dataFormats
.
options
,
[
'
zip
'
,
'
Zip
'
]
as
const
,
[
'
gzip
'
,
'
Gzip
'
]
as
const
];
return
{
url
:
PD
.
Url
(
''
),
format
:
PD
.
Select
(
options
[
0
][
0
],
options
),
...
...
@@ -96,17 +96,23 @@ export const DownloadFile = StateAction.build({
await
state
.
transaction
(
async
()
=>
{
try
{
if
(
params
.
format
===
'
zip
'
)
{
if
(
params
.
format
===
'
zip
'
||
params
.
format
===
'
gzip
'
)
{
// TODO: add ReadZipFile transformer so this can be saved as a simple state snaphot,
// would need support for extracting individual files from zip
const
data
=
await
plugin
.
builders
.
data
.
download
({
url
:
params
.
url
,
isBinary
:
true
});
const
zippedFiles
=
await
unzip
(
taskCtx
,
(
data
.
obj
?.
data
as
Uint8Array
).
buffer
);
for
(
const
[
fn
,
filedata
]
of
Object
.
entries
(
zippedFiles
))
{
if
(
!
(
filedata
instanceof
Uint8Array
)
||
filedata
.
length
===
0
)
continue
;
if
(
params
.
format
===
'
zip
'
)
{
const
zippedFiles
=
await
unzip
(
taskCtx
,
(
data
.
obj
?.
data
as
Uint8Array
).
buffer
);
for
(
const
[
fn
,
filedata
]
of
Object
.
entries
(
zippedFiles
))
{
if
(
!
(
filedata
instanceof
Uint8Array
)
||
filedata
.
length
===
0
)
continue
;
const
asset
=
Asset
.
File
(
new
File
([
filedata
],
fn
));
const
asset
=
Asset
.
File
(
new
File
([
filedata
],
fn
));
await
processFile
(
asset
,
plugin
,
'
auto
'
,
params
.
visuals
);
await
processFile
(
asset
,
plugin
,
'
auto
'
,
params
.
visuals
);
}
}
else
{
const
url
=
Asset
.
getUrl
(
params
.
url
);
const
info
=
getFileInfo
(
url
);
await
processFile
(
Asset
.
File
(
new
File
([
data
.
obj
?.
data
as
Uint8Array
],
info
.
name
)),
plugin
,
'
auto
'
,
params
.
visuals
);
}
}
else
{
const
provider
=
plugin
.
dataFormats
.
get
(
params
.
format
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment