Skip to content

Commit c2ad61a

Browse files
committed
First commit.
0 parents  commit c2ad61a

20 files changed

+1757
-0
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = E501

CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
## [1.1.0] - 2018-01-01
9+
10+
### Changed
11+
12+
- Bumped FS to 2.2.0
13+
14+
## [1.0.0] - 2018-08-17
15+
16+
### Changed
17+
18+
- Version number to advertise stable API
19+
20+
## [0.1.9] - 2018-06-24
21+
22+
### Added
23+
24+
- upload_args and download_args to constructor (Geoff Jukes)
25+
26+
## [0.1.8] - 2018-03-29
27+
28+
### Changed
29+
30+
- Relaxed six dependency
31+
32+
## [0.1.7] - 2018-02-02
33+
34+
### Fixed
35+
36+
- Fix for opening file in missing directory
37+
38+
## [0.1.6] - 2018-01-31
39+
40+
### Added
41+
42+
- implemented new getfile method
43+
44+
### Changed
45+
46+
- Updated fs for more efficient directory walking
47+
- Relaxed boto requirement
48+
49+
## [0.1.5] - 2017-10-21
50+
51+
### Added
52+
53+
- Added 'strict' parameter to constrictor.
54+
55+
## [0.1.4] - 2017-10-15
56+
57+
### Fixed
58+
59+
- copy() wasn't throwing FileExpected exception
60+
- Added keys to oss property
61+
- Exception fixes in OSSFile
62+
63+
### Added
64+
65+
- Added endpoint_url to constructor
66+
67+
## [0.1.3] - 2017-09-01
68+
69+
### Fixed
70+
71+
- Issue with duplicate nested directory names.
72+
73+
### Changed
74+
75+
- Relaxed Boto requirement.
76+
77+
## [0.1.2] - 2017-08-29
78+
79+
### Fixed
80+
81+
- Issue with blank top level subdirectory.
82+
83+
## [0.1.1] - 2017-08-11
84+
85+
### Added
86+
87+
- Added new 'urls' namespace
88+
89+
## [0.1.0] - 2017-08-05
90+
91+
First official release

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 PyFilesystem
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.PHONY: readme
2+
readme:
3+
pandoc --from=markdown --to=rst --output=README.rst README.md
4+
5+
.PHONY: release
6+
release: readme
7+
python setup.py sdist bdist_wheel upload
8+
9+
.PHONY: test
10+
test:
11+
nosetests --with-coverage --cover-erase --logging-level=ERROR --cover-package=fs_ossfs -a "!slow" fs_ossfs/tests
12+
rm .coverage
13+
14+
.PHONY: slowtest
15+
slowtest:
16+
nosetests --with-coverage --cover-erase --logging-level=ERROR --cover-package=fs_ossfs fs_ossfs/tests
17+
rm .coverage
18+
19+
.PHONY: testall
20+
testall:
21+
tox
22+
23+
.PHONY: docs
24+
docs:
25+
cd docs && make html
26+
python -c "import os, webbrowser; webbrowser.open('file://' + os.path.abspath('./docs/_build/html/index.html'))"

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# OSSFS
2+
3+
OSSFS is a [PyFilesystem](https://www.pyfilesystem.org/) interface to
4+
AliCloud OSS cloud storage.
5+
6+
As a PyFilesystem concrete class, [OSSFS](http://fs-ossfs.readthedocs.io/en/latest/) allows you to work with OSS in the
7+
same way as any other supported filesystem.
8+
9+
## Installing
10+
11+
You can install OSSFS from pip as follows:
12+
13+
```
14+
pip install fs-ossfs
15+
```
16+
17+
## Opening a OSSFS
18+
19+
Open an OSSFS by explicitly using the constructor:
20+
21+
```python
22+
from fs_ossfs import OSSFS
23+
ossfs = OSSFS('mybucket')
24+
```
25+
26+
Or with a FS URL:
27+
28+
```python
29+
from fs import open_fs
30+
ossfs = open_fs('oss://mybucket')
31+
```
32+
33+
## Downloading Files
34+
35+
To *download* files from an OSS bucket, open a file on the OSS
36+
filesystem for reading, then write the data to a file on the local
37+
filesystem. Here's an example that copies a file `example.mov` from
38+
OSS to your HD:
39+
40+
```python
41+
from fs.tools import copy_file_data
42+
with ossfs.open('example.mov', 'rb') as remote_file:
43+
with open('example.mov', 'wb') as local_file:
44+
copy_file_data(remote_file, local_file)
45+
```
46+
47+
Although it is preferable to use the higher-level functionality in the
48+
`fs.copy` module. Here's an example:
49+
50+
```python
51+
from fs.copy import copy_file
52+
copy_file(ossfs, 'example.mov', './', 'example.mov')
53+
```
54+
55+
## Uploading Files
56+
57+
You can *upload* files in the same way. Simply copy a file from a
58+
source filesystem to the OSS filesystem.
59+
See [Moving and Copying](https://docs.pyfilesystem.org/en/latest/guide.html#moving-and-copying)
60+
for more information.
61+
62+
## ExtraArgs
63+
64+
OSS objects have additional properties, beyond a traditional
65+
filesystem. These options can be set using the ``upload_args``
66+
and ``download_args`` properties. which are handed to upload
67+
and download methods, as appropriate, for the lifetime of the
68+
filesystem instance.
69+
70+
For example, to set the ``cache-control`` header of all objects
71+
uploaded to a bucket:
72+
73+
```python
74+
import fs, fs.mirror
75+
ossfs = OSSFS('example', upload_args={"CacheControl": "max-age=2592000", "ACL": "public-read"})
76+
fs.mirror.mirror('/path/to/mirror', ossfs)
77+
```
78+
79+
see [the Boto3 docs](https://boto3.readthedocs.io/en/latest/reference/customizations/oss.html#boto3.oss.transfer.OSSTransfer.ALLOWED_UPLOAD_ARGS)
80+
for more information.
81+
82+
`acl` and `cache_control` are exposed explicitly for convenience, and can be used in URLs.
83+
It is important to URL-Escape the `cache_control` value in a URL, as it may contain special characters.
84+
85+
```python
86+
import fs, fs.mirror
87+
with open fs.open_fs('oss://example?acl=public-read&cache_control=max-age%3D2592000%2Cpublic') as ossfs
88+
fs.mirror.mirror('/path/to/mirror', ossfs)
89+
```
90+
91+
92+
## OSS URLs
93+
94+
You can get a public URL to a file on a OSS bucket as follows:
95+
96+
```python
97+
movie_url = ossfs.geturl('example.mov')
98+
```
99+
100+
## Documentation
101+
102+
- [PyFilesystem Wiki](https://www.pyfilesystem.org)
103+
- [OSSFS Reference](http://fs-ossfs.readthedocs.io/en/latest/)
104+
- [PyFilesystem Reference](https://docs.pyfilesystem.org/en/latest/reference/base.html)

README.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
OSSFS
2+
====
3+
4+
OSSFS is a `PyFilesystem <https://www.pyfilesystem.org/>`__ interface to
5+
AliCloud OSS cloud storage.
6+
7+
As a PyFilesystem concrete class,
8+
`OSSFS <http://fs-ossfs.readthedocs.io/en/latest/>`__ allows you to work
9+
with OSS in the same way as any other supported filesystem.
10+
11+
Installing
12+
----------
13+
14+
You can install OSSFS from pip as follows:
15+
16+
::
17+
18+
pip install fs-ossfs
19+
20+
Opening a OSSFS
21+
--------------
22+
23+
Open an OSSFS by explicitly using the constructor:
24+
25+
.. code:: python
26+
27+
from fs_ossfs import OSSFS
28+
ossfs = OSSFS('mybucket')
29+
30+
Or with a FS URL:
31+
32+
.. code:: python
33+
34+
from fs import open_fs
35+
ossfs = open_fs('oss://mybucket')
36+
37+
Downloading Files
38+
-----------------
39+
40+
To *download* files from an OSS bucket, open a file on the OSS filesystem
41+
for reading, then write the data to a file on the local filesystem.
42+
Here's an example that copies a file ``example.mov`` from OSS to your HD:
43+
44+
.. code:: python
45+
46+
from fs.tools import copy_file_data
47+
with ossfs.open('example.mov', 'rb') as remote_file:
48+
with open('example.mov', 'wb') as local_file:
49+
copy_file_data(remote_file, local_file)
50+
51+
Although it is preferable to use the higher-level functionality in the
52+
``fs.copy`` module. Here's an example:
53+
54+
.. code:: python
55+
56+
from fs.copy import copy_file
57+
copy_file(ossfs, 'example.mov', './', 'example.mov')
58+
59+
Uploading Files
60+
---------------
61+
62+
You can *upload* files in the same way. Simply copy a file from a source
63+
filesystem to the OSS filesystem. See `Moving and
64+
Copying <https://docs.pyfilesystem.org/en/latest/guide.html#moving-and-copying>`__
65+
for more information.
66+
67+
ExtraArgs
68+
---------
69+
70+
OSS objects have additional properties, beyond a traditional filesystem.
71+
These options can be set using the ``upload_args`` and ``download_args``
72+
properties. which are handed to upload and download methods, as
73+
appropriate, for the lifetime of the filesystem instance.
74+
75+
For example, to set the ``cache-control`` header of all objects uploaded
76+
to a bucket:
77+
78+
.. code:: python
79+
80+
import fs, fs.mirror
81+
ossfs = OSSFS('example', upload_args={"CacheControl": "max-age=2592000", "ACL": "public-read"})
82+
fs.mirror.mirror('/path/to/mirror', ossfs)
83+
84+
see `the Boto3
85+
docs <https://boto3.readthedocs.io/en/latest/reference/customizations/oss.html#boto3.oss.transfer.OSSTransfer.ALLOWED_UPLOAD_ARGS>`__
86+
for more information.
87+
88+
``acl`` and ``cache_control`` are exposed explicitly for convenience,
89+
and can be used in URLs. It is important to URL-Escape the
90+
``cache_control`` value in a URL, as it may contain special characters.
91+
92+
.. code:: python
93+
94+
import fs, fs.mirror
95+
with open fs.open_fs('oss://example?acl=public-read&cache_control=max-age%3D2592000%2Cpublic') as ossfs
96+
fs.mirror.mirror('/path/to/mirror', ossfs)
97+
98+
OSS URLs
99+
-------
100+
101+
You can get a public URL to a file on a OSS bucket as follows:
102+
103+
.. code:: python
104+
105+
movie_url = ossfs.geturl('example.mov')
106+
107+
Documentation
108+
-------------
109+
110+
- `PyFilesystem Wiki <https://www.pyfilesystem.org>`__
111+
- `OSSFS Reference <http://fs-ossfs.readthedocs.io/en/latest/>`__
112+
- `PyFilesystem
113+
Reference <https://docs.pyfilesystem.org/en/latest/reference/base.html>`__

choppy-ossfs.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

0 commit comments

Comments
 (0)