예제 #1
0
 def loadFromURL(self, ip, url):
     """
     Create a media object sessions and also loads the metadata from the file based on a uploaded file.
     
     ip: remote address
     url: url of the file (string)
     """
     self.ip = ip
     self.uuid =  uuid.uuid4().hex
     # assuming filename is eveything after the rightmost `/'        
     self.filename = helper.strfilter( url[url.rfind('/'):] ,"\\/" )
     self.filedata = urllib.urlopen(url)
     self.filedir = os.path.join (configuration.getDataDir(), self.uuid)
     self.filefullpath = os.path.join (self.filedir, self.filename)
     self.ctime = time.strftime('%d%m%y-%H:%M:%S')
     self.customtags = {}
     self.mtime = self.ctime
     self._savefile()
     self.mediamd = helper.probedata(self.filefullpath)
     self.datasetname = helper.getBaseName(self.filename)
     db.insert_uuid(self.uuid)
     log.debug("filename: " + `self.filename`)
     log.debug("DatasetName (filename w/o extention): " + `self.datasetname`)
예제 #2
0
 def loadFromWeb(self, ip, uploadFilename, uploadData):
     """
     Create a media object sessions and also loads the metadata from the file based on a uploaded file.
     
     ip: remote address
     uploadFilename: upload user name of file (string)
     uploadFile: uploaded user file (file pointer made available by WSGI server)
     """
     log.debug("Filename was: " + uploadFilename )
     self.ip = ip
     self.uuid =  uuid.uuid4().hex
     self.filename = uploadFilename
     self.filedata = uploadData
     self.filedir = os.path.join (configuration.getDataDir(), self.uuid)
     self.filefullpath = os.path.join (self.filedir, self.filename)
     self.ctime = time.strftime('%d%m%y-%H:%M:%S')
     self.customtags = {}
     self.mtime = self.ctime
     self._savefile()
     self.mediamd = helper.probedata(self.filefullpath)
     self.datasetname = helper.getBaseName(self.filename)
     db.insert_uuid(self.uuid)
     log.debug("filename: " + `self.filename`)
     log.debug("DatasetName (filename w/o extention): " + `self.datasetname`)