Skip to content

Commit

Permalink
Merge pull request #29 from minds-ai/fix_largefiles
Browse files Browse the repository at this point in the history
Chunk upload to Google Drive
  • Loading branch information
jbedorf committed Oct 13, 2020
2 parents e8059e4 + 4ac5208 commit a8d77b9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ VOLUME /conf
# Copy wheel from build container into current container and install.
WORKDIR /dist
COPY --from=build /build/dist /dist
RUN python -m pip install zoom_drive_connector-1.1.0-py3-none-any.whl
RUN python -m pip install zoom_drive_connector-1.2.0-py3-none-any.whl

# Create runuser and switch to it.
RUN useradd -ms /bin/false runuser
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ registry can be found
[here](https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry#authenticating-to-github-package-registry).

```bash
$ docker pull docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.1.0
$ docker pull docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.2.0
$ docker run -i -v /path/to/conf/directory:/conf \
docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.1.0
docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.2.0
```

Alternatively, you can clone the repository and run `make build VERSION=1.1.0` to build
Alternatively, you can clone the repository and run `make build VERSION=1.2.0` to build
the container locally. In this case, you will need to exchange the long image name
with the short-form one (`zoom-drive-connector:1.1.0`).
with the short-form one (`zoom-drive-connector:1.2.0`).

This will print an URL, this URL should be copied in the browser. After accepting the
permissions you will be presented with a token. This token should be pasted in the
Expand All @@ -99,7 +99,7 @@ and follow the steps below to run it in the background.
Run the following command to start the container after finishing the setup process.
```bash
$ docker run -d -v /path/to/conf/directory:/conf \
docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.1.0
docker.pkg.github.com/minds-ai/zoom-drive-connector/zoom-drive-connector:1.2.0
```

## Making Changes to Source
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
- mypy=0.641 # Dev dependency.
- pycodestyle=2.4.0 # Dev dependency.
- pylint=1.9.2 # Dev dependency.
- pip
- pip:
- pyyaml>=5.1
- responses==0.10.2 # Dev dependency.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ schedule==0.5.0
google-api-python-client==1.6.7
oauth2client==4.1.2
httplib2shim==0.0.3
httplib2==0.15.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='zoom-drive-connector',
version='1.1.0',
version='1.2.0',
packages=find_packages(exclude=['tests']),
url='https://github.com/minds-ai/zoom-drive-connector',
license='Apache 2.0',
Expand Down
21 changes: 16 additions & 5 deletions zoom_drive_connector/drive/drive_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,24 @@ def upload_file(self, file_path: str, name: str, folder_id: str) -> str:
metadata = {'name': name, 'parents': [folder_id]}

# Create a new upload of the recording and execute it.
media = apiclient.http.MediaFileUpload(file_path, mimetype='video/mp4')
media = apiclient.http.MediaFileUpload(file_path,
mimetype='video/mp4',
chunksize=1024*1024,
resumable=True
)

# pylint: disable=no-member
uploaded_file = self._service\
.files()\
.create(body=metadata, media_body=media, fields='webViewLink', supportsTeamDrives=True)\
.execute()
request = self._service.files().create(body=metadata,
media_body=media,
fields='webViewLink',
supportsTeamDrives=True
)
response = None
while response is None:
status, response = request.next_chunk()
if status:
print(f"Uploaded {int(status.progress() * 100)}%")
uploaded_file = request.execute()

log.log(logging.INFO, f'File {file_path} uploaded to Google Drive')

Expand Down

0 comments on commit a8d77b9

Please sign in to comment.