Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading images along with Google App Engine

I'm working on a Google App Engine project.

My app is working and looking correct locally, but when I try to upload images in an image directory, they're not being displayed at appspot.

As a little troubleshoot, I put a HTML page in "/images/page2.html" and I can load that page at the appspot, but my pages don't display my images. So, it's not a problem with my path.

As another sanity check, I'm also uploading a style sheet directory with .css code in it, and that's being read properly.

I have a suspicion that the problem lies in my app.yaml file.

Any ideas?

I don't want to paste all the code here, but here are some of the key lines. The first two work fine. The third does not work:

<link type="text/css" rel="stylesheet" href="/stylesheets/style.css" />
<a href="/images/Page2.html">Page 2</a>
<img src="/images/img.gif">

This is my app.yaml file

application: myApp
version: 1
runtime: python
api_version: 1

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /images
  static_dir: images

- url: /.*
  script: helloworld.py
like image 675
Baltimark Avatar asked Oct 02 '08 03:10

Baltimark


People also ask

How do I upload files to Google engine?

In the Google Cloud console, go to the VM instances page. In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to. After the connection is established, click the upload icon upload. The upload dialog opens.

Is Google App Engine deprecated?

In Google I/O 2011, Google announced App Engine Backends, which are allowed to run continuously, and consume more memory. The Backend API was deprecated as of March 13, 2014 in favor of the Modules API.

How do I upload an image to GCP?

Drag and drop the desired files from your desktop or file manager to the main pane in the Google Cloud console. Click the Upload Files button, select the files you want to upload in the dialog that appears, and click Open.


1 Answers

You have to configure app.yaml for static content such as images and css files

Example:

 url: /(.*\.(gif|png|jpg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg))

For more info check out: http://code.google.com/appengine/docs/configuringanapp.html

like image 120
Sarp Centel Avatar answered Sep 28 '22 08:09

Sarp Centel