import os
import logging
import tempfile

from sevenbridges.errors import (
    SbgError,
    ResourceNotModified,
    LocalFileAlreadyExists
)
from sevenbridges.meta.fields import (
    HrefField, StringField, IntegerField, CompoundField, DateTimeField,
    BasicListField
)
from sevenbridges.meta.resource import Resource
from sevenbridges.models.bulk import BulkRecord
from sevenbridges.transfer.upload import Upload
from sevenbridges.decorators import inplace_reload
from sevenbridges.transfer.download import Download
from sevenbridges.meta.transformer import Transform
from sevenbridges.models.compound.files.metadata import Metadata
from sevenbridges.models.enums import PartSize, RequestParameters
from sevenbridges.models.compound.files.file_storage import FileStorage
from sevenbridges.models.compound.files.file_origin import FileOrigin
from sevenbridges.models.compound.files.download_info import DownloadInfo

logger = logging.getLogger(__name__)


class File(Resource):
    """
    Central resource for managing files.
    """
    FOLDER_TYPE = 'folder'

    _URL = {
        'query': '/files',
        'scroll': '/files/scroll',
        'get': '/files/{id}',