Google app engine Image upload removes previous files - google-app-engine

I am fairly new to Google App Engine. When I keep files in images folder and run bat file, it uploads images properly but when I remove those images and put new images to upload, it removes previous images.
My app.yaml looks like this
application: testcdn
version: 1
runtime: python27
api_version: 1
threadsafe: true
default_expiration: "1d 1h"
handlers:
- url: /css
static_dir: css
- url: /images
static_dir: images
- url: /js
static_dir: js
- url: /.*
static_files: index.html
upload: index.html
Also when 2 developers try to upload images to the same cdn store with different google accounts, it removes images previously uploaded by other developer.
Please suggest.

Your local files mirror your deployed files. If you remove files locally, then deploy, the remote files will be deleted. You are not just defining the files to upload, but the files to mirror remotely.
I am not sure about your 2nd comment. Do the files have the same filenames? You will have to provide the upload code for diagnosis.

Related

app.yaml cannot call my css file for my index.php

I have create an app in php. The folder "myapp-test-1" has a file called index.php and a folder CSS which includes the file main.css which is the css file for index.php .I am trying to create my app yaml file in order to upload my project in google's app engine. This is my app.yaml file:
application: myapp-test-1
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: index.php
- url: /css
static_dir: css
- url: /css/
script: main.css
when test it in browser it seems that index.php file is not full loaded. Moreover the css for index.php is not working.
You need to have the
- url: /.*
script: index.php
last, because if you have it first, the order in which GAE will read this file is this, then the other two css ones. The regex .* next to url says that all URLs will lead to index.php, so putting this last will allow GAE to read the css ones first. You also don't need to include
- url: /css/
script: main.css
if you're only going to load the css files in your index.php.
So overall, it should look like
application: myapp-test-1
version: 1
runtime: php
api_version: 1
handlers:
- url: /css
static_dir: css
- url: /.*
script: index.php
I believe that you should try to leave only :
- url: /.*
script: path/index.php
and remove the two references to the css.
from inside the index.php, make sure that you call your css file using the right path.
eventually if you use firefox, the function "inspect element" and the console, will tell you why your file is not loaded...
good luck

Images not loading in site hosted on Google App Engine

I am trying to host my site on Google APP Engine. I have configured my app.yaml file and deployed the website. All the files deployed correctly including the css and js files. What I am facing trouble with are the image files. I am getting a 404 resource not found error in my console for the images that my static web page is using. I am not sure what the problem is. Here is the structure of my site
index.html
view(folder)
-images
-abc.png
-xyz.png
-js
-css
Here is the code in app.yaml
- url: /(.*\.png)
mime_type: image/png
static_files: template/\1
upload: template/(.*\.png)
Wanted to know if the app.yaml is configured correctly to go through the images folder and then upload my image files.
You are pointing to the template directory in app.yaml, but you images are actually in a directory tree branched as view/images. Try this:
- url: /(.*\.png)
mime_type: image/png
static_files: view/images/\1
upload: view/images/(.*\.png)

Google app engine website page structure

I made a website using Google app engine however, if I want to link from the main page to a different page in the folder structure, is does not load on the website.
The links are fine, they work if I check it on a browser directly from my drive. Do I need to put the entire folder in a seperate folder somewhere for app engine to access it or does it need to be in one single, messy file?
Check the app.yaml file, you have to edit it and add the folders.
Ex:
application: xxxx
version: 1
runtime: python
api_version: 1
handlers:
- url: /stylesheets
static_dir: resources/stylesheets
- url: /imgs
static_dir: resources/imgs
- url: /js
static_dir: resources/js
- url: /html
static_dir: resources/html
mime_type: text/html
- url: /.*
script: main.py
You have to put all your files that you want to display directly through an HTTP call in WEB-INF folder, assuming that you are coding in Java.

Google AppEngine app.yaml error 500

I'm having problems getting my assets folder to upload to the root, but also allowing a custom url handler /cron to upload too.
application: appname
version: 1
runtime: python
api_version: 1
handlers:
- url: /cron
script: assets/backup/main.py
- url: /
static_files: assets/index.html
upload: assets/index.html
- url: /
static_dir: assets
As you can see, my backup script is also located in my assets or static folder. If I remove my static_dir: assets handler, my /cron handler works fine.
I also tried changing the url to /assets to see if I could overwrite it that way.
Any idea why this happens and how I can fix it?
You are defining the whole assets directory as static with static_dir: assets. You can't run any script inside a static_dir. The fix is to move assets/backup/main.py to outside the directory defined as static_dir.

Is it possible to host a static html website in google app engine?

How do I set index.html for the default root web page?
application: dfischerdna version: 1
runtime: python api_version: 1
handlers:
- url: /
static_dir: static_files
This works great when the visitor types
http://dfischerdna.appspot.com/index.html
However I would like that when he types this, the index.html web page would be displayed.
http://dfischerdna.appspot.com/ -> goes to 404 page
This might do the trick for you:
handlers:
- url: /
static_files: path/to/index.html
upload: local/path/to/index.html
- url: /(.+)
static_files: path/to/\1
upload: local/path/to/(.+)
The first url section will match the root URL and serve path/to/index.html. The second will match any path other than the root path, and will serve the file located under path/to that the request URI matches. For the URL http://yourapp.appspot.com/index.html it will serve path/to/index.html, and for a URL like http://yourapp.appspot.com/foo/bar.html it will serve path/to/foo/bar.html.
The upload directive tells GAE which local files to upload to serve as static files in your app instance.

Resources