-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathremote_file.py
More file actions
57 lines (46 loc) · 1.22 KB
/
remote_file.py
File metadata and controls
57 lines (46 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional
from pydantic.v1 import BaseModel
class RemoteFile(BaseModel):
"""
A file in a file-based stream.
"""
uri: str
last_modified: datetime
mime_type: Optional[str] = None
class UploadableRemoteFile(RemoteFile, ABC):
"""
A file in a file-based stream that supports uploading(file transferring).
"""
id: Optional[str] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
@property
@abstractmethod
def size(self) -> int:
"""
Returns the file size in bytes.
"""
...
@abstractmethod
def download_to_local_directory(self, local_file_path: str) -> None:
"""
Download the file from remote source to local storage.
"""
...
@property
def source_file_relative_path(self) -> str:
"""
Returns the relative path of the source file.
"""
return self.uri
@property
def file_uri_for_logging(self) -> str:
"""
Returns the URI for the file being logged.
"""
return self.uri