-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(drive): document upload and download
- Loading branch information
1 parent
fb7977e
commit 602fb6a
Showing
18 changed files
with
537 additions
and
64 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
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
41 changes: 41 additions & 0 deletions
41
...google/google-drive/src/main/java/io/camunda/connector/gdrive/LoggerProgressListener.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,41 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. Licensed under a proprietary license. | ||
* See the License.txt file for more information. You may not use this file | ||
* except in compliance with the proprietary license. | ||
*/ | ||
package io.camunda.connector.gdrive; | ||
|
||
import com.google.api.client.googleapis.media.MediaHttpUploader; | ||
import com.google.api.client.googleapis.media.MediaHttpUploaderProgressListener; | ||
import java.io.IOException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Resumable upload official example: <a | ||
* href="https://developers.google.com/api-client-library/java/google-api-java-client/media-upload#implementation">...</a> | ||
*/ | ||
public class LoggerProgressListener implements MediaHttpUploaderProgressListener { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerProgressListener.class); | ||
|
||
@Override | ||
public void progressChanged(MediaHttpUploader uploader) throws IOException { | ||
switch (uploader.getUploadState()) { | ||
case NOT_STARTED: | ||
LOGGER.debug("Upload not started"); | ||
break; | ||
case INITIATION_STARTED: | ||
LOGGER.debug("Initiation has started!"); | ||
break; | ||
case INITIATION_COMPLETE: | ||
LOGGER.debug("Initiation is complete!"); | ||
break; | ||
case MEDIA_IN_PROGRESS: | ||
LOGGER.debug("Upload progress: {}", uploader.getProgress()); | ||
break; | ||
case MEDIA_COMPLETE: | ||
LOGGER.debug("Upload is complete!"); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../google/google-drive/src/main/java/io/camunda/connector/gdrive/mapper/DocumentMapper.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,29 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. Licensed under a proprietary license. | ||
* See the License.txt file for more information. You may not use this file | ||
* except in compliance with the proprietary license. | ||
*/ | ||
package io.camunda.connector.gdrive.mapper; | ||
|
||
import com.google.api.services.drive.model.File; | ||
import io.camunda.connector.api.outbound.OutboundConnectorContext; | ||
import io.camunda.document.Document; | ||
import io.camunda.document.store.DocumentCreationRequest; | ||
|
||
public class DocumentMapper { | ||
|
||
private final OutboundConnectorContext context; | ||
|
||
public DocumentMapper(OutboundConnectorContext context) { | ||
this.context = context; | ||
} | ||
|
||
public Document mapToDocument(byte[] bytes, File fileMetaData) { | ||
return context.createDocument( | ||
DocumentCreationRequest.from(bytes) | ||
.contentType(fileMetaData.getMimeType()) | ||
.fileName(fileMetaData.getName()) | ||
.build()); | ||
} | ||
} |
Oops, something went wrong.