Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SR2-projet1-VANDEWAETER
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio Vandewaeter
SR2-projet1-VANDEWAETER
Commits
8d9fe4e3
Commit
8d9fe4e3
authored
1 month ago
by
fabiovandewaeter
Browse files
Options
Downloads
Patches
Plain Diff
upload dossier
parent
f557b7ed
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+3
-3
3 additions, 3 deletions
README.md
src/main/java/fil/sr2/flopbox/FTPService.java
+14
-3
14 additions, 3 deletions
src/main/java/fil/sr2/flopbox/FTPService.java
with
17 additions
and
6 deletions
README.md
+
3
−
3
View file @
8d9fe4e3
...
...
@@ -107,12 +107,12 @@ unzip dossier1.zip
curl
-X
PUT
-H
"Authorization: Bearer valid-token-1"
-H
"X-FTP-User: user"
-H
"X-FTP-Pass: password"
--upload-file
fichier2 http://localhost:8080/ftps/mon-ftp/fichier2
```
-
upload dossier
(ne fonctionne pas bien pour le moment je crois)
:
-
upload dossier :
```
shell
curl
-X
PUT
-H
"Authorization: Bearer valid-token-1"
-H
"X-FTP-User: user"
-H
"X-FTP-Pass: password"
--upload-file
dossier2.zip http://localhost:8080/ftps/mon-ftp/
dossier2
.zip
zip
-r
dossier2.zip
dossier2
curl
-X
POST
-H
"Authorization: Bearer valid-token-1"
-H
"X-FTP-User: user"
-H
"X-FTP-Pass: password"
-H
"Content-Type: application/octet-stream"
--data-binary
@dossier2.zip http://localhost:8080/ftps/mon-ftp/upload-dir/
curl
-X
POST
-H
"Authorization: Bearer valid-token-1"
-H
"X-FTP-User: user"
-H
"X-FTP-Pass: password"
-H
"Content-Type: application/octet-stream"
--data-binary
@dossier2.zip http://localhost:8080/ftps/mon-ftp/upload-dir/
dossier2
```
**Note comprise entre 12 et 13 si—en plus—le proxy FlopBox, permet de télécharger (download) et téléverser (upload) un gros fichier binaire (image, vidéo, etc.):**
...
...
This diff is collapsed.
Click to expand it.
src/main/java/fil/sr2/flopbox/FTPService.java
+
14
−
3
View file @
8d9fe4e3
...
...
@@ -13,6 +13,7 @@ import java.util.zip.ZipInputStream;
import
java.net.URLDecoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
import
java.io.ByteArrayInputStream
;
public
class
FTPService
{
...
...
@@ -350,12 +351,22 @@ public class FTPService {
}
}
private
void
uploadFileEntry
(
FTPClient
ftp
,
String
path
,
InputStream
is
)
private
void
uploadFileEntry
(
FTPClient
ftp
,
String
path
,
Zip
InputStream
z
is
)
throws
IOException
,
FTPException
{
String
fileName
=
path
.
contains
(
"/"
)
?
path
.
substring
(
path
.
lastIndexOf
(
'/'
)
+
1
)
:
path
;
try
(
InputStream
bais
=
is
)
{
if
(!
ftp
.
storeFile
(
fileName
,
bais
))
{
// Lire le contenu du fichier dans un tableau d'octets
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
4096
];
int
bytesRead
;
while
((
bytesRead
=
zis
.
read
(
buffer
))
!=
-
1
)
{
baos
.
write
(
buffer
,
0
,
bytesRead
);
}
// Uploader le contenu depuis le tableau d'octets
try
(
InputStream
bis
=
new
ByteArrayInputStream
(
baos
.
toByteArray
()))
{
if
(!
ftp
.
storeFile
(
fileName
,
bis
))
{
throw
new
FTPException
(
"Échec upload: "
+
path
,
500
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment