在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):juleswhite/mobile-cloud-asgn1开源软件地址(OpenSource Url):https://github.com/juleswhite/mobile-cloud-asgn1开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):Assignment 1Running the ApplicationTo run the application: Right-click on the Application class in the org.magnum.dataup package, Run As->Java Application To stop the application: Open the Eclipse Debug Perspective (Window->Open Perspective->Debug), right-click on the application in the "Debug" view (if it isn't open, Window->Show View->Debug) and select Terminate OverviewA popular use of cloud services is to manage media that is uploaded from mobile devices. This assignment will create a very basic application for uploading video to a cloud service and managing the video's metadata. Once you are able to build this basic type of infrastructure, you will have the core knowledge needed to create much more sophisticated cloud services. InstructionsFirst, clone this Git repository and import it into Eclipse as a Gradle Project. You can do this from the "File" menu by selecting "Import". Expand the "Gradle" option and then choose "Existing Gradle Project". Select the root folder of this project and then hit "Finish". This assignment tests your ability to create a web application that allows clients to upload videos to a server. The server allows clients to first upload a video's metadata (e.g., duration, etc.) and then to upload the actual binary data for the video. The server should support uploading video binary data with a multipart request. The test that is used to grade your implementation is AutoGradingTest in the org.magnum.dataup package in src/test/java. You should use the source code in the AutoGradingTest as the ground truth for what the expected behavior of your solution is. Your app should pass this test without any errors. The test methods are annotated with @Rubric and specify the number of points associated with each test, the purpose of the test, and the videos relevant to the test. The HTTP API that you must implement so that this test will pass is as follows: GET /video
POST /video
POST /video/{id}/data
GET /video/{id}/data
The AutoGradingTest should be used as the ultimate ground truth for what should be implemented in the assignment. If there are any details in the description above that conflict with the AutoGradingTest, use the details in the AutoGradingTest as the correct behavior and report the discrepancy on the course forums. Further, you should look at the AutoGradingTest to ensure that you understand all of the requirements. It is perfectly OK to post on the forums and ask what a specific section of the AutoGradingTest does. Do not, however, post any code from your solution or potential solution. There is a VideoSvcApi interface that is annotated with Retrofit annotations in order to communicate with the video service that you will be creating. Your solution controller(s) should not directly implement this interface in a "Java sense" (e.g., you should not have YourSolution implements VideoSvcApi). Your solution should support the HTTP API that is described by this interface, in the text above, and in the AutoGradingTest. In some cases it may be possible to have the Controller and the client implement the interface, but it is not in this Again -- the ultimate ground truth of how the assignment will be graded, is contained in AutoGradingTest, which shows the specific tests that will be run to grade your solution. You must implement everything that is required to make all of the tests in this class pass. If a test case is not mentioned in this README file, you are still responsible for it and will be graded on whether or not it passes. Make sure and read the AutoGradingTest code and look at each test! You should not modify any of the code in Video, VideoStatus, VideoSvcApi, AutoGrading, or AutoGradingTest. Testing Your ImplementationTo test your solution, first run the application as described above. Once your application is running, you can right-click on the AutoGradingTest->Run As->JUnit Test to launch the test. Eclipse will report which tests pass or fail. To get an estimated score for your solution, right-click on AutoGrading (not AutoGradingTest) and Run As->Java Application. The AutoGrading application will run AutoGradingTest and then print a summary of the test results and your score to the Eclipse Console (Window->Show View->Console). The AutoGrading application will also create a submission package that you will submit as the solution to the assignment in Coursera. Submitting Your AssignmentTo submit your assignment, you must first run the AutoGrading application as described in the previous step to create your submission package. Make sure that you take note of the name of the submission package that is printed in the console to ensure that you submit the correct file. You should submit the submission package that is generated as the solution file on Coursera's website. After submitting your solution to Coursera, your submission package will be sent to the auto-grading servers. It may take a few minutes for a score to be assigned to your submission. Once the submission is graded, a detailed score will be registered with Coursera. Note: locally running the AutoGrading application DOES NOT submit your solution to Coursera and will not be counted as a valid submission. The grade that you see when running the AutoGrading application is an estimate of your grade only. You must correctly submit the solution to Coursera to receive an official grade. Provided Code
Video video = Video.create().withContentType("video/mpeg")
.withDuration(123).withSubject("Mobile Cloud")
.withTitle("Programming Cloud Services for ...").build(); You can also accept a Video from an application/json request body or return the JSON of a video like this: @RequestMapping(value = "/funny/video", method = RequestMethod.POST)
public @ResponseBody Video addVideo(@RequestBody Video v){
// Do something with the Video
// ...
return v;
}
// Initialize this member variable somewhere with
// videoDataMgr = VideoFileManager.get()
//
private VideoFileManager videoDataMgr;
// You would need some Controller method to call this...
public void saveSomeVideo(Video v, MultipartFile videoData) throws IOException {
videoDataMgr.saveVideoData(video, videoData.getInputStream());
}
public void serveSomeVideo(Video v, HttpServletResponse response) throws IOException {
// Of course, you would need to send some headers, etc. to the
// client too!
// ...
videoDataMgr.copyVideoData(v, response.getOutputStream());
} Hints
...
@RequestMapping("/some/path/{id}")
public MyObject doSomething(
@PathVariable("id") String id,
@RequestParam("something") String data,
HttpServletResponse response) {
// Maybe you want to set the status code with the response
// or write some binary data to an OutputStream obtained from
// the HttpServletResponse object
....
}
public class SomeClass implements VideoSvcApi // Don't implement this interface!
{
...
}
private String getDataUrl(long videoId){
String url = getUrlBaseForLocalServer() + "/video/" + videoId + "/data";
return url;
}
private String getUrlBaseForLocalServer() {
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String base =
"http://"+request.getServerName()
+ ((request.getServerPort() != 80) ? ":"+request.getServerPort() : "");
return base;
}
private static final AtomicLong currentId = new AtomicLong(0L);
private Map<Long,Video> videos = new HashMap<Long, Video>();
public Video save(Video entity) {
checkAndSetId(entity);
videos.put(entity.getId(), entity);
return entity;
}
private void checkAndSetId(Video entity) {
if(entity.getId() == 0){
entity.setId(currentId.incrementAndGet());
}
} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论