Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mauro Paolo Josue Zuñiga Mallqui
trismegisto-services
Commits
f6da5199
Commit
f6da5199
authored
Nov 29, 2024
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADÐ] DESCARGA DE ARCHIVOS DRIVE API
parent
1d09c733
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
DriveService.java
...ask/trismegistoservices/services/google/DriveService.java
+5
-2
No files found.
src/main/java/web/multitask/trismegistoservices/services/google/DriveService.java
View file @
f6da5199
...
...
@@ -6,6 +6,7 @@ import java.util.Collections;
import
lombok.AllArgsConstructor
;
import
org.json.JSONObject
;
import
org.springframework.core.io.InputStreamResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
...
...
@@ -69,8 +70,8 @@ public class DriveService implements IDriveService {
try
{
File
file
=
googleConfig
.
getDrive
().
files
().
get
(
file_id
).
execute
();
InputStream
inputStream
=
googleConfig
.
getDrive
().
files
().
get
(
file_id
).
executeMediaAsInputStream
();
java
.
io
.
File
tempFile
=
new
java
.
io
.
File
(
System
.
getProperty
(
"java.io.tmpdir"
)
+
"/temp."
+
file
.
getName
().
split
(
"\\."
)[
1
]
);
tempFile
.
deleteOnExit
(
);
String
uudi
=
java
.
util
.
UUID
.
randomUUID
().
toString
(
);
java
.
io
.
File
tempFile
=
new
java
.
io
.
File
(
System
.
getProperty
(
"java.io.tmpdir"
)
+
"/"
+
uudi
+
"."
+
file
.
getName
().
split
(
"\\."
)[
1
]
);
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
tempFile
))
{
byte
[]
buffer
=
new
byte
[
1024
];
int
bytesRead
;
...
...
@@ -78,8 +79,10 @@ public class DriveService implements IDriveService {
fos
.
write
(
buffer
,
0
,
bytesRead
);
}
}
if
(
base64
)
{
String
base64String
=
commonUtils
.
fileToBase64
(
tempFile
);
tempFile
.
delete
();
// Eliminación inmediata en modo Base64
return
ResponseEntity
.
ok
().
body
(
new
JSONObject
()
.
put
(
"base64"
,
base64String
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment