Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
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
OpenEdx
pyfs
Commits
4d291172
Commit
4d291172
authored
Oct 21, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added getpathurl, implemented by Marek Palatinus
parent
5cac7314
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
fs/s3fs.py
+30
-0
No files found.
fs/s3fs.py
View file @
4d291172
...
@@ -193,6 +193,36 @@ class S3FS(FS):
...
@@ -193,6 +193,36 @@ class S3FS(FS):
key
.
set_contents_from_file
(
contents
)
key
.
set_contents_from_file
(
contents
)
return
self
.
_sync_key
(
key
)
return
self
.
_sync_key
(
key
)
def
makepublic
(
self
,
path
):
"""Mark given path as publicly accessible using HTTP(S)"""
s3path
=
self
.
_s3path
(
path
)
k
=
self
.
_s3bukt
.
get_key
(
s3path
)
k
.
make_public
()
def
getpathurl
(
self
,
path
,
allow_none
=
False
,
expires
=
3600
):
"""Returns a url that corresponds to the given path."""
s3path
=
self
.
_s3path
(
path
)
k
=
self
.
_s3bukt
.
get_key
(
s3path
)
# Is there AllUsers group with READ permissions?
is_public
=
True
in
[
grant
.
permission
==
'READ'
and
\
grant
.
uri
==
'http://acs.amazonaws.com/groups/global/AllUsers'
for
grant
in
k
.
get_acl
()
.
acl
.
grants
]
url
=
k
.
generate_url
(
expires
,
force_http
=
is_public
)
if
url
==
None
:
if
not
allow_none
:
raise
NoPathURLError
(
path
=
path
)
return
None
if
is_public
:
# Strip time token; it has no sense for public resource
url
=
url
.
split
(
'?'
)[
0
]
return
url
def
setcontents
(
self
,
path
,
contents
):
def
setcontents
(
self
,
path
,
contents
):
s3path
=
self
.
_s3path
(
path
)
s3path
=
self
.
_s3path
(
path
)
self
.
_sync_set_contents
(
s3path
,
contents
)
self
.
_sync_set_contents
(
s3path
,
contents
)
...
...
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