Exemplo n.º 1
0
	def get(self,fid):
		matches=False
		if "iPhone" in self.request.headers["User-Agent"] or "Android" in self.request.headers["User-Agent"]:
			matches=True
		if matches:
			print "Mobile"
			mobile=True
		else:
			print "Desktop"
			mobile=False
		prefetchFilelist=apriori1.fileList

		filelist=FileInfo.all()
		filelist.filter('user ='******'User-Agent']
		if fid:
			new_file=FileInfo.get_by_id(long(fid))
			
			if not new_file:
				self.error(404)
				return
			self.render_template("upload.html",{'post_url':blobstore.create_upload_url('/uploaded'),'mobile':mobile,'new_file':new_file,'filelist':filelist,'ua':ua,'logout_url':users.create_logout_url('/'),
			})
		else:
			self.render_template("upload.html",{'post_url':blobstore.create_upload_url('/uploaded'),'mobile':mobile,'filelist':filelist,'ua':ua,'logout_url':users.create_logout_url('/'),
			})
Exemplo n.º 2
0
	def post(self):
		blob_info=self.get_uploads()[0]
		if self.request.get('folder'):
			folder_name=self.request.get('folder')
		else:
			folder_name="Root"
		if folder_name=="Create New":
			self.redirect("/createfolder/%d" %d dbentry.key().id())
		dbentry=FileInfo(blobkey=blob_info.key(),user=users.get_current_user(),folder=folder_name)
		db.put(dbentry)
		self.redirect("/list/%d" % dbentry.key().id())
Exemplo n.º 3
0
	def get(self,fid):
		filelist=FileInfo.all()
		filelist=filelist.filter('user ='******'new_file':new_file,'filelist':filelist,'logout_url':users.create_logout_url('/'),
			})
		else:
			self.render_template("list.html",{'filelist':filelist,'logout_url':users.create_logout_url('/'),
			})
Exemplo n.º 4
0
	def get(self,fid):
		delete_file=FileInfo.get_by_id(long(fid))
		db.delete(delete_file)
		blobstore.delete([delete_file.blobkey])
#		filelist=FileInfo.all()
#		filelist=filelist.filter('user =', users.get_current_user())
		self.redirect("/list/")
Exemplo n.º 5
0
	def post(self):
		blob_info=self.get_uploads()[0]
		typeoffile=blob_info.content_type
		isimage=False
		print typeoffile
		if typeoffile=='image/png' or typeoffile=='image/jpeg':
			isimage=True
			dbentryi=Photo(blobkey=blob_info.key(),serving_url=db.Link(images.get_serving_url(blob_info.key())))
			db.put(dbentryi)
		if (users.get_current_user()):
			dbentry=FileInfo(blobkey=blob_info.key(),user=users.get_current_user(),is_image=isimage)
		else:
			dbentry=FileInfo(blobkey=blob_info.key(),user=User('*****@*****.**'),is_image=isimage)
		
		db.put(dbentry)
		accessentry=Apriori(file_id=str(dbentry.key().id()))
		db.put(accessentry)
		self.redirect("/%d" % dbentry.key().id())
Exemplo n.º 6
0
	def get(self,fid):
		accessentry=Apriori(file_id=str(fid))
		db.put(accessentry)
    
		file_info=FileInfo.get_by_id(long(fid))
		if not file_info or not file_info.blobkey:
			self.error(404)
			return
		self.send_blob(file_info.blobkey,save_as=True)
Exemplo n.º 7
0
	def get(self):
		filelist=FileInfo.all()
		if not filelist:
			self.render_template("upload.html",{
				'post_url':blobstore.create_upload_url('/uploaded'),'logout_url':users.create_logout_url('/'),
				})
		else:
			self.render_template("upload.html",{
				'post_url':blobstore.create_upload_url('/uploaded'),'filelist':filelist,'logout_url':users.create_logout_url('/'),
				})
Exemplo n.º 8
0
    def do_view(self):
	filelist=FileInfo.all()
	#print "users.get_current_user()"
	filelist.filter('user ='******'*****@*****.**'))

	for file in filelist:
		self.response.out.write("\n<table border=1>\n")
		self.response.out.write("<tr>\n<td>Filename</td><td>%s</td>\n</tr>" % file.blobkey.filename)
		self.response.out.write("<tr>\n<td>Size</td><td>%s</td>\n</tr>" % file.blobkey.size)
		self.response.out.write("<tr>\n<td>User</td><td>%s</td>\n</tr>" % file.user)
		self.response.out.write("<tr>\n<td>Time</td><td>%s</td>\n</tr>" % file.upload_time)
		self.response.out.write("<tr>\n<td>ContentType</td><td>%s</td>\n</tr>" % file.blobkey.content_type)
		self.response.out.write("\n</table>\n")
Exemplo n.º 9
0
    def do_getFile(self):
	fid=0
	filename=self.request.get("filename")
	print "Download",filename
	filelist=FileInfo.all()
	print users.get_current_user()
	filelist.filter('user ='******'*****@*****.**'))
	for f in filelist:
		if f.blobkey.filename==filename:
			print "YEs",f.blobkey.filename,f.key().id()
			fid=f.key().id()
			break
	#response = urllib2.urlopen("/file/fid/download")
    	#print response
    	print fid
#	response=urllib2.urlopen("godatacloud.appspot.com/file/"+fid+"/download")
#	print fid
#	print response
#	localFile = open(filename, 'w')
#	localFile.write(response.read())
#	response.close()
#	localFile.close()
	self.response.out.write("<tr>\n<td>%s</td><td>%s</td>\n</tr>" % (filename,fid))
Exemplo n.º 10
0
	def get(self,fid):
		imagefile=FileInfo.get_by_id(long(fid))
		image=Photo.all().filter('blobkey =',imagefile.blobkey.key()).get()
		self.render_template("thumbnail.html",{'image':image,'logout_url':users.create_logout_url('/'),
			})
Exemplo n.º 11
0
	def get(self,fid):
		file_info=FileInfo.get_by_id(long(fid))
		if not file_info or not file_info.blobkey:
			self.error(404)
			return
		self.send_blob(file_info.blobkey,save_as=True)