Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest-fs-openacs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest-fs-openacs
Commits
0947edaa
Commit
0947edaa
authored
Jan 07, 2019
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- First version downloading and uploading
parent
89a7fe42
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
4 deletions
+132
-4
intranet-rest-fs-openacs-procs.tcl
tcl/intranet-rest-fs-openacs-procs.tcl
+23
-0
file-tree.json.tcl
www/file-tree.json.tcl
+5
-4
mkdir.tcl
www/mkdir.tcl
+46
-0
upload.tcl
www/upload.tcl
+58
-0
No files found.
tcl/intranet-rest-fs-openacs-procs.tcl
View file @
0947edaa
...
...
@@ -16,6 +16,29 @@ ad_library {
#
# ---------------------------------------------------------------------
ad_proc -public im_rest_fs_folder_for_path
{
-object_id:required
-path:required
}
{
Returns the ID of the cr_folder related to the given path
below object
}
{
ns_log Notice
"im_rest_fs_folder_for_path: object_id=
$object
_id, path=
$path
"
set folder_id
[
im_rest_fs_folder_for_object -object_id
$object
_id
]
set path_pieces
[
split
$path
"/"
]
foreach piece
$path
_pieces
{
ns_log Notice
"im_rest_fs_folder_for_path: folder_id=
$folder
_id: searching for '
$piece
'"
set folder_id
[
db_string sub_folder
"
select min(item_id)
from cr_items ci
where parent_id = :folder_id and
lower(name) = lower(:piece)
"
]
}
return
$folder
_id
}
ad_proc -public im_rest_fs_folder_for_object
{
-object_id
...
...
www/file-tree.json.tcl
View file @
0947edaa
...
...
@@ -64,10 +64,11 @@ set sql "
cr.*,
CASE WHEN bts.open_p = 'o' THEN 'true' ELSE 'false' END as expanded,
CASE
WHEN ci.content_type::text = 'content_folder'::text THEN 'folder'::character varying
WHEN ci.content_type::text = 'content_extlink'::text THEN 'url'::character varying
WHEN ci.content_type::text = 'content_symlink'::text THEN 'symlink'::character varying
ELSE cr.mime_type
WHEN ci.content_type::text = 'content_folder' THEN 'folder'
WHEN ci.content_type::text = 'content_extlink' THEN 'url'
WHEN ci.content_type::text = 'content_symlink' THEN 'symlink'
WHEN ci.content_type::text = 'file_storage_object' THEN 'file'
ELSE ci.content_type
END AS type
from cr_items parent_ci,
cr_items ci
...
...
www/mkdir.tcl
0 → 100644
View file @
0947edaa
ad_page_contract
{
page to add a new file to the system
@author Kevin Scaldeferri
(
kevin@arsdigita.com
)
@creation-date 6 Nov 2000
@cvs-id $Id$
}
{
{
project_id:integer
""
}
{
path
""
}
}
set
user_id
[
ad_conn user_id
]
set
package_id
[
ad_conn package_id
]
set
package_id
[
db_string package
"select min(package_id) from apm_packages where package_key = 'file-storage'"
-default
$package
_id
]
ns_log Notice
"mkdir: path=
$path
, project_id=
$project
_id"
if
{
""
ne
$project
_id
}
{
set folder_id
[
im_rest_fs_folder_for_object -object_id
$project
_id
]
}
set
file_id
[
db_nextval
"acs_object_id_seq"
]
set
path_pieces
[
split
$path
"/"
]
set
parent_pieces
[
lrange
$path
_pieces 0 end-1
]
set
folder_name
[
lindex
$path
_pieces end
]
ns_log Notice
"mkdir: path=
$path
, parent_pieces=
$parent
_pieces, folder_name=
$folder
_name"
set
parent_id
[
im_rest_fs_folder_for_path -object_id
$project
_id -path
[
join
$parent
_pieces
"/"
]]
if
{
""
eq
$parent
_id
}
{
doc_return 500
"text/plain"
"Did not find path=
$path
for object_id=
$object
_id"
ad_script_abort
}
fs::new_folder
\
-name
$folder
_name
\
-pretty_name
$folder
_name
\
-parent_id
$parent
_id
\
-creation_user
$user
_id
\
-creation_ip
[
ad_conn peeraddr
]
\
-package_id
$package
_id
doc_return 200
"text/plain"
"project_id=
$project
_id, path=
$path
"
ad_script_abort
www/upload.tcl
0 → 100644
View file @
0947edaa
ad_page_contract
{
page to add a new file to the system
@author Kevin Scaldeferri
(
kevin@arsdigita.com
)
@creation-date 6 Nov 2000
@cvs-id $Id$
}
{
project_id:integer
{
path
""
}
upload_file:trim,optional
upload_file.tmpfile:tmpfile,optional
{
title
""
}
{
description
"description"
}
}
set
user_id
[
ad_conn user_id
]
set
n_bytes
[
file
size
${upload_file.tmpfile}
]
set
package_id
[
ad_conn package_id
]
set
package_id
[
db_string package
"select min(package_id) from apm_packages where package_key = 'file-storage'"
-default
$package
_id
]
ns_log Notice
"upload: project_id=
$project
_id, path=
$path
, upload_file=
$upload
_file, tmp_file=
${upload_file.tmpfile}
"
set
ttt
{
set
max_bytes
[
parameter::get -parameter
"MaximumFileSize"
]
if
{
$n
_bytes >
$max
_bytes
}
{
ad_return_complaint 1
"Your file is larger than the maximum file size allowed on this system (
[
util_commify_number
$max
_bytes
]
bytes)"
ad_script_abort
}
}
set
folder_id
[
im_rest_fs_folder_for_path -object_id
$project
_id -path
$path
]
set
mime_type
[
cr_filename_to_mime_type -create --
$upload
_file
]
set
file_id
[
db_nextval
"acs_object_id_seq"
]
ns_log Notice
"upload: folder_id=
$folder
_id, file_id=
$file
_id, mime_type=
$mime
_type"
if
{
1
}
{
fs::add_file
\
-name
$upload
_file
\
-item_id
$file
_id
\
-parent_id
$folder
_id
\
-tmp_filename
${upload_file.tmpfile}
\
-creation_user
$user
_id
\
-creation_ip
[
ad_conn peeraddr
]
\
-title
$upload
_file
\
-description
$description
\
-package_id
$package
_id
\
-mime_type
$mime
_type
}
file
delete
${upload_file.tmpfile}
ns_log Notice
"upload: Finished"
doc_return 200
"text/plain"
"project_id=
$project
_id, path=
$path
, file_id=
$file
_id, folder_id=
$folder
_id, upload_file=
$upload
_file, tmp_file=
${upload_file.tmpfile}
, cont="
ad_script_abort
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment