airbyte_cdk.sources.file_based.remote_file
1# 2# Copyright (c) 2023 Airbyte, Inc., all rights reserved. 3# 4from abc import ABC, abstractmethod 5from datetime import datetime 6from typing import Optional 7 8from pydantic.v1 import BaseModel 9 10 11class RemoteFile(BaseModel): 12 """ 13 A file in a file-based stream. 14 """ 15 16 uri: str 17 last_modified: datetime 18 mime_type: Optional[str] = None 19 20 @property 21 def file_uri_for_logging(self) -> str: 22 """Returns a user-friendly identifier for logging.""" 23 return self.uri 24 25 26class UploadableRemoteFile(RemoteFile, ABC): 27 """ 28 A file in a file-based stream that supports uploading(file transferring). 29 """ 30 31 id: Optional[str] = None 32 created_at: Optional[str] = None 33 updated_at: Optional[str] = None 34 35 @property 36 @abstractmethod 37 def size(self) -> int: 38 """ 39 Returns the file size in bytes. 40 """ 41 ... 42 43 @abstractmethod 44 def download_to_local_directory(self, local_file_path: str) -> None: 45 """ 46 Download the file from remote source to local storage. 47 """ 48 ... 49 50 @property 51 def source_file_relative_path(self) -> str: 52 """ 53 Returns the relative path of the source file. 54 """ 55 return self.uri 56 57 @property 58 def source_uri(self) -> str: 59 """ 60 Returns the Source URI for the file being logged. 61 """ 62 return self.uri
class
RemoteFile(pydantic.v1.main.BaseModel):
12class RemoteFile(BaseModel): 13 """ 14 A file in a file-based stream. 15 """ 16 17 uri: str 18 last_modified: datetime 19 mime_type: Optional[str] = None 20 21 @property 22 def file_uri_for_logging(self) -> str: 23 """Returns a user-friendly identifier for logging.""" 24 return self.uri
A file in a file-based stream.
27class UploadableRemoteFile(RemoteFile, ABC): 28 """ 29 A file in a file-based stream that supports uploading(file transferring). 30 """ 31 32 id: Optional[str] = None 33 created_at: Optional[str] = None 34 updated_at: Optional[str] = None 35 36 @property 37 @abstractmethod 38 def size(self) -> int: 39 """ 40 Returns the file size in bytes. 41 """ 42 ... 43 44 @abstractmethod 45 def download_to_local_directory(self, local_file_path: str) -> None: 46 """ 47 Download the file from remote source to local storage. 48 """ 49 ... 50 51 @property 52 def source_file_relative_path(self) -> str: 53 """ 54 Returns the relative path of the source file. 55 """ 56 return self.uri 57 58 @property 59 def source_uri(self) -> str: 60 """ 61 Returns the Source URI for the file being logged. 62 """ 63 return self.uri
A file in a file-based stream that supports uploading(file transferring).
size: int
36 @property 37 @abstractmethod 38 def size(self) -> int: 39 """ 40 Returns the file size in bytes. 41 """ 42 ...
Returns the file size in bytes.
@abstractmethod
def
download_to_local_directory(self, local_file_path: str) -> None:
44 @abstractmethod 45 def download_to_local_directory(self, local_file_path: str) -> None: 46 """ 47 Download the file from remote source to local storage. 48 """ 49 ...
Download the file from remote source to local storage.
source_file_relative_path: str
51 @property 52 def source_file_relative_path(self) -> str: 53 """ 54 Returns the relative path of the source file. 55 """ 56 return self.uri
Returns the relative path of the source file.
source_uri: str
58 @property 59 def source_uri(self) -> str: 60 """ 61 Returns the Source URI for the file being logged. 62 """ 63 return self.uri
Returns the Source URI for the file being logged.