-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
361 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/io/github/rukins/gkeepapi/client/GKeepMediaClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.rukins.gkeepapi.client; | ||
|
||
import feign.Headers; | ||
import feign.Param; | ||
import feign.RequestLine; | ||
import feign.Response; | ||
|
||
public interface GKeepMediaClient { | ||
String URL = "https://keep.google.com"; | ||
|
||
// it automatically redirects to https://lh3.googleusercontent.com/keep-bbsk/... | ||
// (that is located in Location header of the response) and returns image bytes | ||
@RequestLine("GET /media/v2/{node-serverId}/{blob-serverId}") // ?accept=audio/3gpp,audio/amr-wb,image/gif,image/jpg,image/jpeg,image/png&sz=2148 | ||
@Headers({ | ||
"Authorization: OAuth {access-token}" | ||
}) | ||
Response media( | ||
@Param("blob-serverId") String blobServerId, | ||
@Param("node-serverId") String nodeServerId, | ||
@Param("access-token") String accessToken | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/io/github/rukins/gkeepapi/client/GKeepUploadMediaClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.rukins.gkeepapi.client; | ||
|
||
import feign.Headers; | ||
import feign.Param; | ||
import feign.RequestLine; | ||
import feign.Response; | ||
import io.github.rukins.gkeepapi.model.gkeep.node.blob.blobobject.ImageBlob; | ||
|
||
public interface GKeepUploadMediaClient { | ||
String URL = "https://notes-pa.googleapis.com"; | ||
|
||
@RequestLine("POST /upload/notes/v1/media/{blob-serverId}?noteId={node-serverId}&uploadType=resumable") | ||
@Headers({ | ||
"Connection: Keep-Alive", | ||
"Authorization: OAuth {access-token}" | ||
}) | ||
Response uploadMedia( | ||
@Param("blob-serverId") String blobServerId, | ||
@Param("node-serverId") String nodeServerId, | ||
@Param("access-token") String accessToken | ||
); | ||
|
||
@RequestLine("PUT /upload/notes/v1/media/{blob-serverId}?noteId={node-serverId}&uploadType=resumable&upload_id={upload_id}") | ||
@Headers({ | ||
"Connection: Keep-Alive" | ||
}) | ||
ImageBlob uploadMedia( | ||
@Param("file") byte[] imageBytes, | ||
@Param("blob-serverId") String blobServerId, | ||
@Param("node-serverId") String nodeServerId, | ||
@Param("upload_id") String uploadId | ||
); | ||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/io/github/rukins/gkeepapi/model/image/ImageData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package io.github.rukins.gkeepapi.model.image; | ||
|
||
import io.github.rukins.gkeepapi.model.gkeep.node.blob.MimeType; | ||
|
||
public class ImageData { | ||
private byte[] bytes; | ||
private Integer byteSize; | ||
private String fileName; | ||
private MimeType mimeType; | ||
private ImageSize imageSize; | ||
|
||
public ImageData(byte[] bytes, String fileName, MimeType mimeType) { | ||
this.bytes = bytes; | ||
this.byteSize = bytes.length; | ||
this.fileName = fileName; | ||
this.mimeType = mimeType; | ||
} | ||
|
||
public ImageData(byte[] bytes, String fileName, MimeType mimeType, ImageSize imageSize) { | ||
this.bytes = bytes; | ||
this.byteSize = bytes.length; | ||
this.fileName = fileName; | ||
this.mimeType = mimeType; | ||
this.imageSize = imageSize; | ||
} | ||
|
||
public byte[] getBytes() { | ||
return bytes; | ||
} | ||
|
||
public void setBytes(byte[] bytes) { | ||
this.bytes = bytes; | ||
} | ||
|
||
public Integer getByteSize() { | ||
return byteSize; | ||
} | ||
|
||
public void setByteSize(Integer byteSize) { | ||
this.byteSize = byteSize; | ||
} | ||
|
||
public String getFileName() { | ||
return fileName; | ||
} | ||
|
||
public void setFileName(String fileName) { | ||
this.fileName = fileName; | ||
} | ||
|
||
public MimeType getMimeType() { | ||
return mimeType; | ||
} | ||
|
||
public void setMimeType(MimeType mimeType) { | ||
this.mimeType = mimeType; | ||
} | ||
|
||
public ImageSize getImageSize() { | ||
return imageSize; | ||
} | ||
|
||
public void setImageSize(ImageSize imageSize) { | ||
this.imageSize = imageSize; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ImageData{" + | ||
"byteSize=" + byteSize + | ||
", fileName='" + fileName + '\'' + | ||
", mimeType='" + mimeType + '\'' + | ||
", imageSize=" + imageSize + | ||
'}'; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/rukins/gkeepapi/model/image/ImageSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.rukins.gkeepapi.model.image; | ||
|
||
public class ImageSize { | ||
private Integer width; | ||
private Integer height; | ||
|
||
public ImageSize(Integer width, Integer height) { | ||
this.width = width; | ||
this.height = height; | ||
} | ||
|
||
public Integer getWidth() { | ||
return width; | ||
} | ||
|
||
public void setWidth(Integer width) { | ||
this.width = width; | ||
} | ||
|
||
public Integer getHeight() { | ||
return height; | ||
} | ||
|
||
public void setHeight(Integer height) { | ||
this.height = height; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ImageSize{" + | ||
"width=" + width + | ||
", height=" + height + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.