|
1 | 1 | package com.creatubbles.api; |
2 | 2 |
|
3 | 3 | import com.creatubbles.api.core.Creation; |
| 4 | +import com.creatubbles.api.core.Credentials; |
4 | 5 | import com.creatubbles.api.core.Gallery; |
5 | | -import com.creatubbles.api.core.Image; |
| 6 | +import com.creatubbles.api.request.amazon.GetAmazonTokenRequest; |
6 | 7 | import com.creatubbles.api.request.amazon.UploadS3ImageRequest; |
7 | 8 | import com.creatubbles.api.request.auth.SignInRequest; |
8 | 9 | import com.creatubbles.api.request.creation.UpdateCreationRequest; |
9 | 10 | import com.creatubbles.api.request.creation.UploadCreationRequest; |
| 11 | +import com.creatubbles.api.response.amazon.GetAmazonTokenResponse; |
10 | 12 | import com.creatubbles.api.response.auth.SignInResponse; |
11 | 13 | import com.creatubbles.api.response.auth.SignUpResponse; |
12 | | -import com.creatubbles.api.response.creation.UpdateCreationResponse; |
13 | 14 | import com.creatubbles.api.response.creation.UploadCreationResponse; |
14 | 15 | import com.creatubbles.api.response.creator.CreateCreatorResponse; |
15 | 16 | import com.creatubbles.api.response.gallery.CreateUserGalleryResponse; |
@@ -45,18 +46,26 @@ public static String buildURL(final String endPoint) { |
45 | 46 | } |
46 | 47 |
|
47 | 48 | public static void main(String[] args) throws IOException { |
| 49 | + //login |
48 | 50 | SignInResponse response = new SignInRequest("jevgeni.koltsin@gmail.com", "ccttbb").execute().getResponse(); |
49 | 51 | System.out.println(response.access_token); |
| 52 | + //create creation |
50 | 53 | UploadCreationResponse uploadResponse = new UploadCreationRequest(response.access_token).execute().getResponse(); |
| 54 | + //get required info for s3 |
| 55 | + GetAmazonTokenResponse amazonTokenResponse = new GetAmazonTokenRequest(response.access_token).execute().getResponse(); |
| 56 | + Credentials credentials = amazonTokenResponse.credentials; |
51 | 57 | //TODO: last screenshot |
52 | 58 | File file = new File("C:/dev/1.png"); |
53 | 59 | byte[] data = Files.readAllBytes(file.toPath()); |
54 | 60 | String fileName = System.currentTimeMillis() + "creation.png"; |
55 | 61 | Creation creation = uploadResponse.creation; |
56 | 62 | String relativePath = creation.store_dir + "/" + fileName; |
57 | | - new UploadS3ImageRequest(data, relativePath).execute().getResponse(); |
| 63 | + //upload image |
| 64 | + new UploadS3ImageRequest(data, relativePath, credentials.access_key_id, credentials.secret_access_key, credentials.session_token) |
| 65 | + .execute().getResponse(); |
58 | 66 | creation.url = relativePath; |
59 | | - UpdateCreationResponse updateResponse = new UpdateCreationRequest(response.access_token, creation).execute().getResponse(); |
| 67 | + //update creation(url) |
| 68 | + new UpdateCreationRequest(response.access_token, creation).execute().getResponse(); |
60 | 69 | System.exit(0); |
61 | 70 | } |
62 | 71 | } |
0 commit comments