代写 COS80001 - Software Development for Cloud Computing
100%原创包过,高质量代写&免费提供Turnitin报告--24小时客服QQ&微信:273427
代写 COS80001 - Software Development for Cloud Computing
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 1
COS80001 - Software Development for Cloud Computing
Assignment 2: Web album with Amazon EC2 and S3
- Graded as Pass (1) / Fail (0) (Individual Work)
Due: Week 5 (at your allocated lab on Tuesday Apr 05 or Thursday Apr 07, 2016)
- Hardcopy at the start of lab session, identical softcopy to Blackboard
Objectives
1. Learn to use AWS S3 with AWS console and S3 APIs
2. Learn to program in JAVA and JSP to communicate with AWS S3
3. Create your own photo album Website with AWS EC2 and S3
Content
The photo album will be deployed in the EC2 instance created in Assignment 1. For
data storage, the photos, originally on your local computer, will be stored on Amazon
S3 afterwards. Detailed activities are listed as follows:
1. Create your bucket in S3 (one off)
2. Create your Access Keys (one off)
3. Learn to program using Java in JSP pages
4. Learn to upload and display your photos with S3 API in AWS SDK.
5. Create your own Web photo album on AWS
Activity 1: Create your bucket in S3 (one off)
Amazon Simple Storage Service (Amazon S3 for short) is a Cloud storage service
provided by AWS. You can use S3 to store and retrieve any amount of data at any
time, from anywhere on the Web. S3 stores data in the form of objects within buckets.
An object can be redeemed as a file plus the metadata that describes that file.
In order to create a bucket in S3, sign in with your Amazon account and open the
S3 management console. S3 management console is similar to Figure 1.
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 2
Figure 1
Now you can create your bucket. The bucket name is global which means you
need to set an identical bucket name. You must select “Sydney” as your region, as
shown in Figure 2. After creation, you can select your bucket to create a new folder or
upload any files to this bucket directly.
Figure 2
By default, the bucket as well as the files uploaded are only accessable by
yourself. In order to allow users to access object in your bucket via the Internet,
please add bucket policy accordingly (see Figure 3 where the policy is specified in the
2 nd link below). For details of the bucket policy and editing object permissions, please
refer to the following links:
http://docs.aws.amazon.com/AmazonS3/latest/UG/EditingPermissionsonanObject.html
http://havecamerawilltravel.com/photographer/how-allow-public-access-amazon-bucket
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 3
代写 COS80001 - Software Development for Cloud Computing
Figure 3
Note
1. For this assignment, please upload files with the size as small as possible. On one
hand, it takes time to upload a very large file. On the other hand, the storage of the
file will be charged by AWS. Therefore, in general you should not upload the file
that is more than 100KB.
2. You can access the file via Web browser by using its link. Simply select the file
and click “properties” on the upper right corner, and you can find the link shown.
Activity 2: Create your Access Keys on AWS (one off)
In order to programmatically request AWS services, e.g. upload/download files in
S3 bucket, Access Keys are required. Access Keys are security protections that will
prevent other users to access your own resources on AWS. Please follow the steps to
create your own Access Keys:
1. Sign in with your Amazon account. On top right of the AWS home page,
you can see your name. Click your name-> Security Credentials. You
will be redirected to the Security Credentials management page which is
similar to Figure 4. Click “Continue to Security Credentials” to disable
the popup dialog.
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 4
Figure 4
2. Click “Access Keys (Access Key ID and Secret Access Key)” ->
“Create New Access Key”. Then your keys including Access Key ID and
Secret Access Key will be created automatically. You MUST download
and save your key file to a safe place in order to use them later while
creating your own web photo albums on AWS. You can also view your
key file on the page similar to Figure 5.
Figure 5
Activity 3: Learn to program using Java in JSP pages
In Assignment 1, the “Hello World!” example implemented in Java and JSP page was
provided. In that assignment, we mentioned that you can get the source code of the
application. After you have read the source code, you can have a basic understanding
for Java programming in a JSP page. However, in order to complete this assignment,
you need to get familiar with how to call Java method and output HTTP code in JSP
pages. Here, we provide materials related to Java programming within JSP pages. By
learning these materials, you will be able to use JSP page to upload photos on your
local computer to the Tomcat Web server in your EC2 instance.
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 5
First, you need to get familiar with the JSP page structure and learn how to insert
Java codes into a JSP page. Please refer to the following link or similar tutorials:
http://www.ntu.edu.sg/home/ehchua/programming/java/JSPByExample.html
Second, you need to learn to write Java code and edit JSP pages in Eclipse. Please
refer to the following link or similar tutorials:
http://www.javatpoint.com/creating-jsp-in-eclipse-ide
Third, in order to transfer data to the Tomcat Web server in your EC2 instance,
you need to know how to use forms in html. Please refer to the following link or
similar tutorials:
http://www.w3schools.com/html/html_forms.asp
Fourth, in order to upload a local file to the Tomcat Web server in your EC2
instance using JSP pages, you need to learn how to use html forms in
“multipart/form-data” format and use Java to parse the file as well as other useful
information. Please refer to the following link or similar tutorials where Java code
template is available at:
http://corejavaexample.blogspot.com.au/2013/04/how-to-upload-file-in-jsp.html
Activity 4: Learn to upload and display the photo album with S3 API
in AWS SDK
By learning the related skills addressed in the previous activity, now you are able to
upload your photos from your local computer to the Tomcat Web server in your EC2
instance. Once a photo is uploaded to the Web server, you need to learn how to store
it in S3 by using AWS S3 APIs. Please refer to the following link or similar tutorials
where Java code template is available at:
http://www.stefanolocati.it/blog/?p=786
Also, you need to learn how to get all the addresses of the photos in your
bucket/folder, so that you can list them and show them in the JSP page. Please refer to
the following link or similar tutorials where Java code template for listing an S3
bucket’s content is available at:
https://ceph.com/docs/master/radosgw/s3/java/
Note
A photo can be processed as a byte array and uploaded to S3 like that. In order to
retrieve the byte array as a photo again, simply output the byte array to a file and set
the corresponding file name extension.
Activity 5: Create your own Web photo album on AWS
After completion of the above activities, now you should have sufficient knowledge
to create your own Web photo album on AWS using EC2 and S3. Similar to the
“Hello World!” application in Assignment 1, the photo album should be a Web site
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 6
that interacts with users via JSP pages. On one hand, it receives the upload request
from the user side and parses the photo from the posted content. On the other hand, it
stores the photo in S3 and returns the photo address back to the user so that the
photo(s) in S3 can be viewed.
Based on Activity 2, you are able to upload your photo files with HTML forms
into the Tomcat Web server in your EC2 instance. Based on Activity 3, you are able
to make the uploaded photo files stored in S3. In addition, based on Activity 3, you
are also able to retrieve the address of the photo files in S3.
For completing all the functions of the photo album, you may need to create
several JSPs. For example, one can be for uploading photos and one can be for
displaying all photos. Here we demonstrate a simple photo album example to give you
a direct look-and-feel of what the photo album should look like as shown in Figures 6
and 7. Figure 6 shows the JSP page for uploading a photo and Figure 7 shows the JSP
page for displaying the photos.
Figure 6
Figure 7
Note
1. On all the desktops in the Faculty Computer Labs, we have set up the software
development environment for you. For accessing all the applications, their paths
in the lab computers are given as follows:
JDK: C:\Program Files\Java\jdk1.8.0_72
Eclipse for J2EE developers: C:\Program Files\Eclipse IDE for Java EE
Developers Mars.1\eclipse.exe
Tomcat: C:\Program Files (x86)\apache-tomcat-8.0.30
2. For setting up the environment on your own computers for improving your
productivity, we provide a guideline which is available on blackboard along with
assignment specification.
3. For making the photo album, you should create a Dynamic Web Project in Eclipse
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 7
for J2EE developers for development before you deploy on AWS. In order to use
the AWS APIs, you need to import AWS SDK into your development
environment as described next. Please note that you cannot just add them into the
libarary of the “Java resources”, as they may not be packaged into the WAR file.
Our solution is to import all the JAR files required for AWS into the “lib” folder
(project -> WebContent -> WEB-INF -> lib) and add these files into the build
path. After this step, you are ready to develop your Web photo album. We have
uploaded the required JAR files to S3. You need to download the following 20
files (See Figure 8) via the following address:
https://s3-ap-southeast-2.amazonaws.com/cloudcomputingunit/AWS_JARs.zip
Figure 8
4. After developing your photo album Website locally, you need to export your
Dynamic Web Project as war file (*.war) to your local drive. Then you can
upload the war file, which is rather big due to packages listed in Figure 8, into the
“webapps” directory of Tomcat Web server in your Windows EC2 instance on
AWS.
5. In order to show a photo in a JSP page, you can add an HTML image tag, i.e.
“<img src='address of the photo'/>”. When the JSP page is running,
the photo will be displayed.
6. You need to (re)start your EC2 instance created and stopped before. After you log
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 8
on to AWS, go to “Instances”, you can find your own EC2 instance. Similar to
“stop” that you did before, you can “start” it. Again, do not forget to stop your
EC2 instance at the end of your activities to avoid the unnecessary cost charged by
AWS.
Submission
You are required to submit a report focusing on the tasks listed in Activity 5 –
softcopy to Blackboard and an identical hardcopy at the start of your lab session for
marking:
1. The document must contain your name, student id, and unit code as well as a title
(e.g. Submission for Assignment 2).
2. Screenshots similar to Figures 6 and 7 to show your pages for uploading a photo
from your local computer and displaying stored photo(s) on S3 via Web browser.
3. A list of JSP / Java programs with source code in the report. All source code
MUST be submitted in plain text format in the report so turnitin can check for
plagiarism. Your programs should have some basic comments for understanding
you code.
The report is assessed and returned to you in the lab session with feedback if any. You
are expected to incorporate the feedback (esp. if changes are required) and submit the
changed report as part of the final portfolio.
Note
This is a formative assignment. That is, an assignment designed to provide feedback.
If you fail this assignment, you have 1 week to make corrections and resubmit to pass.
Demonstration
You will be asked to demonstrate your assignment in the lab. For demonstration, you
need to have one photo already in S3 and then you demonstrate that you can upload a
new photo first and display both photos afterwards, i.e. existing one and newly
uploaded one.
FAQ
What happens if assignment submission is graded as a ‘fail’?
You will have to repeat the task and submit in the following week’s lab session.
Students can repeat the task and submit for feedback again. If your submission is
graded as ‘fail’ twice then you may fail this unit.
Faculty of Science, Engineering and Technology Swinburne University of Technology
COS80001 9
What happens if a student is unable to submit the assignment?
If you are unable to submit due to medical reasons, then a doctor certificate will have
to be shown. In normal conditions, all students are expected to make a submission by
the due date, otherwise the assignment is graded as a fail.
代写 COS80001 - Software Development for Cloud Computing