def __init__(self, open_request, file_storage):
    self.filename = open_request.filename()
    self.file_storage = file_storage
    self.blob_reader = None
    self.content_type = None
    self.mime_content_type = None

    open_mode = open_request.open_mode()
    content_type = open_request.content_type()

    if not self.filename.startswith(_BLOBSTORE_DIRECTORY):
      if not self.file_storage.has_blobstore_file(self.filename):
        raise_error(file_service_pb.FileServiceErrors.INVALID_FILE_NAME)

    self.ticket = self.filename[len(_BLOBSTORE_DIRECTORY):]

    if open_mode == file_service_pb.OpenRequest.APPEND:
      if not self.file_storage.has_blobstore_file(self.filename):
        raise_error(file_service_pb.FileServiceErrors.EXISTENCE_ERROR)

      if self.file_storage.is_finalized(self.filename):
        raise_error(file_service_pb.FileServiceErrors.FINALIZATION_ERROR,
                    'File is already finalized')

      self.mime_content_type = self.file_storage.get_content_type(self.filename)
      self.blob_file_name = self.file_storage.get_blob_file_name(self.filename)
    else:
      if self.ticket.startswith(files._CREATION_HANDLE_PREFIX):
        blobkey = self.file_storage.get_blob_key(self.ticket)
        if not blobkey:
          raise_error(file_service_pb.FileServiceErrors.FINALIZATION_ERROR,
                      'Blobkey not found.')
      else:
        blobkey = self.ticket

      blob_info = blobstore.BlobInfo.get(blobkey)

      if not blob_info:
        raise_error(file_service_pb.FileServiceErrors.FINALIZATION_ERROR,
                    'Blobinfo not found.')

      self.blob_reader = blobstore.BlobReader(blob_info)
      self.mime_content_type = blob_info.content_type

    if content_type != file_service_pb.FileContentType.RAW:
      raise_error(file_service_pb.FileServiceErrors.WRONG_CONTENT_TYPE)
Constructor.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/files/file_service_stub.py/BlobstoreFile.__init__