def get_ofs(): """ Return a configured instance of the appropriate OFS driver, in all cases here this will be the local file storage so we fix the implementation to use pairtree. """ return get_impl("pairtree")(storage_dir=storage_dir)
def get_ofs(): storage_backend = config['ofs.impl'] kw = {} for k,v in config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v ofs = get_impl(storage_backend)(**kw) return ofs
def ofs(self): if not hasattr(self, "_ofs"): kw = {} for k,v in self.config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v self._ofs = get_impl(self.config.get('ofs.impl', 'google'))(**kw) return self._ofs
def get_ofs(): storage_backend = config.get('ofs.impl') kw = {} for k in config.keys(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = config.get(k) ofs = get_impl(storage_backend)(**kw) return ofs
def ofs(self): if not hasattr(self, "_ofs"): kw = {} for k, v in self.config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v self._ofs = get_impl(self.config.get('ofs.impl', 'google'))(**kw) return self._ofs
def get_ofs(): """Return a configured instance of the appropriate OFS driver. """ storage_backend = config['ofs.impl'] kw = {} for k,v in config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v ofs = get_impl(storage_backend)(**kw) return ofs
def get_ofs(): """Return a configured instance of the appropriate OFS driver. """ storage_backend = config['ofs.impl'] kw = {} for k, v in config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v ofs = get_impl(storage_backend)(**kw) return ofs
def get(self, environ, start_response): is_head = environ['REQUEST_METHOD'].upper() == 'HEAD' print("Getting a resource *******************************S") print(self.filename) #Home Office Edit start if (isLocalFile(self.filename)): print("Is a local file") if 'max-age=0' in CACHE_CONTROL(environ).lower(): self.update(force=True) # RFC 2616 13.2.6 else: self.update() #Home Office Edit end if not self.content: #Home office edit start if isLocalFile( self.filename) and not os.path.exists(self.filename): print("Is a local file") #Home office edit end exc = HTTPNotFound('The resource does not exist', comment="No file at %r" % self.filename) return exc(environ, start_response) try: #Home Office Edit start print("Is not a local file") ofs_impl = config.get('ofs.impl') if (isLocalFile(self.filename)): #then treat it as local storage file = open(self.filename, 'rb') else: kw = {} kw['aws_access_key_id'] = config[ 'ofs.s3.aws_access_key_id'] kw['aws_secret_access_key'] = config[ 'ofs.s3.aws_secret_access_key'] ofs = get_impl('s3')(**kw) BUCKET = config['ofs.s3.bucket'] print("Getting the file from AWS") print(BUCKET) print(self.filename) self.content_length = ofs.get_metadata( BUCKET, self.filename)['_content_length'] file = ofs.get_stream(BUCKET, self.filename, as_stream=True) #Home Office Edit end except (IOError, OSError), e: exc = HTTPForbidden( 'You are not permitted to view this file (%s)' % e) return exc.wsgi_application(environ, start_response)
def get_ofs(): """Return a configured instance of the appropriate OFS driver. """ storage_backend = config["ofs.impl"] kw = {} for k, v in config.items(): if not k.startswith("ofs.") or k == "ofs.impl": continue kw[k[4:]] = v # Make sure we have created the marker file to avoid pairtree issues if storage_backend == "pairtree" and "storage_dir" in kw: create_pairtree_marker(kw["storage_dir"]) ofs = get_impl(storage_backend)(**kw) return ofs
def get_ofs(): """Return a configured instance of the appropriate OFS driver. """ storage_backend = config['ofs.impl'] kw = {} for k, v in config.items(): if not k.startswith('ofs.') or k == 'ofs.impl': continue kw[k[4:]] = v # Make sure we have created the marker file to avoid pairtree issues if storage_backend == 'pairtree' and 'storage_dir' in kw: create_pairtree_marker(kw['storage_dir']) ofs = get_impl(storage_backend)(**kw) return ofs
def get(self, environ, start_response): is_head = environ['REQUEST_METHOD'].upper() == 'HEAD' print("Getting a resource *******************************S") print(self.filename) #Home Office Edit start if(isLocalFile(self.filename)): print("Is a local file") if 'max-age=0' in CACHE_CONTROL(environ).lower(): self.update(force=True) # RFC 2616 13.2.6 else: self.update() #Home Office Edit end if not self.content: #Home office edit start if isLocalFile(self.filename) and not os.path.exists(self.filename): print("Is a local file") #Home office edit end exc = HTTPNotFound( 'The resource does not exist', comment="No file at %r" % self.filename) return exc(environ, start_response) try: #Home Office Edit start print("Is not a local file") ofs_impl = config.get('ofs.impl') if(isLocalFile(self.filename)): #then treat it as local storage file = open(self.filename, 'rb') else: kw = {} kw['aws_access_key_id'] = config['ofs.s3.aws_access_key_id'] kw['aws_secret_access_key'] = config['ofs.s3.aws_secret_access_key'] ofs = get_impl('s3')(**kw) BUCKET = config['ofs.s3.bucket'] print("Getting the file from AWS") print(BUCKET) print(self.filename) self.content_length = ofs.get_metadata(BUCKET, self.filename)['_content_length'] file = ofs.get_stream(BUCKET, self.filename, as_stream=True) #Home Office Edit end except (IOError, OSError), e: exc = HTTPForbidden( 'You are not permitted to view this file (%s)' % e) return exc.wsgi_application( environ, start_response)