|
1 | 1 | S3FS
|
2 | 2 | ====
|
3 | 3 |
|
4 |
| -S3FS is a `PyFilesystem interface <https://docs.pyfilesystem.org/>`__ to |
| 4 | +S3FS is a `PyFilesystem <https://www.pyfilesystem.org/>`__ interface to |
5 | 5 | Amazon S3 cloud storage.
|
6 | 6 |
|
7 |
| -As a PyFilesystem concrete class, S3FS allows you to work with S3 in the |
8 |
| -same as any other supported filesystem. |
| 7 | +As a PyFilesystem concrete class, |
| 8 | +`S3FS <http://fs-s3fs.readthedocs.io/en/latest/>`__ allows you to work |
| 9 | +with S3 in the same way as any other supported filesystem. |
9 | 10 |
|
10 |
| -`Documentation <http://fs-s3fs.readthedocs.io/en/latest/>`__ |
| 11 | +Opening a S3FS |
| 12 | +-------------- |
| 13 | + |
| 14 | +Open an S3FS by explicitly using the constructor: |
| 15 | + |
| 16 | +.. code:: python |
| 17 | +
|
| 18 | + from s3_s3fs import s3FS |
| 19 | + s3fs = S3FS('mybucket') |
| 20 | +
|
| 21 | +Or with a FS URL: |
| 22 | + |
| 23 | +.. code:: python |
| 24 | +
|
| 25 | + from fs import open_fs |
| 26 | + s3fs = open_fs('s3://mybucket') |
| 27 | +
|
| 28 | +Downloading Files |
| 29 | +----------------- |
| 30 | + |
| 31 | +To *download* files from an S3 bucket, open a file on the S3 filesystem |
| 32 | +for reading, then write the data to a file on the local filesystem. |
| 33 | +Here's an example that copies a file ``example.mov`` from S3 to your HD: |
| 34 | + |
| 35 | +.. code:: python |
| 36 | +
|
| 37 | + from fs.tools import copy_file_data |
| 38 | + with s3fs.open('example.mov', 'rb') as remote_file: |
| 39 | + with open('example.mov', 'wb') as local_file: |
| 40 | + copy_file_data(remote_file, local_file) |
| 41 | +
|
| 42 | +Although it is preferable to use the higher-level functionality in the |
| 43 | +``fs.copy`` module. Here's an example: |
| 44 | + |
| 45 | +.. code:: python |
| 46 | +
|
| 47 | + from fs.copy import copy_file |
| 48 | + copy_file(s3fs, 'example.mov', './', 'example.mov') |
| 49 | +
|
| 50 | +Uploading Files |
| 51 | +--------------- |
| 52 | + |
| 53 | +You can *upload* files in the same way. Simply copy a file from a source |
| 54 | +filesystem to the S3 filesystem. See `Moving and |
| 55 | +Copying <https://docs.pyfilesystem.org/en/latest/guide.html#moving-and-copying>`__ |
| 56 | +for more information. |
| 57 | + |
| 58 | +S3 URLs |
| 59 | +------- |
| 60 | + |
| 61 | +You can get a public URL to a file on a S3 bucket as follows: |
| 62 | + |
| 63 | +.. code:: python |
| 64 | +
|
| 65 | + movie_url = s3fs.geturl('example.mov') |
| 66 | +
|
| 67 | +Documentation |
| 68 | +------------- |
| 69 | + |
| 70 | +- `PyFilesystem Wiki <https://www.pyfilesystem.org>`__ |
| 71 | +- `S3FS Reference <http://fs-s3fs.readthedocs.io/en/latest/>`__ |
| 72 | +- `PyFilesystem |
| 73 | + Reference <https://docs.pyfilesystem.org/en/latest/reference/base.html>`__ |
0 commit comments