Comments (8)
Hi Hoheckell ! Could you show us your config/filesystems.php
file ?
from laravel-sftp.
`<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/
'default' => 'local',
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => 's3',
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'sftp' => [
'driver' => 'sftp',
'host' => env('SFTP_HOST', ''),
'port' => env('SFTP_PORT', '21'),
'username' => env('SFTP_USERNAME', ''),
'password' => env('SFTP_PASSWORD', ''),
'privateKey' => env('SFTP_PRIVATE_KEY_PATH', ''),
'root' => env('SFTP_ROOT', ''),
'timeout' => env('SFTP_TIMEOUT', '10'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
'pdfs' => [
'driver' => 'local',
'root' => public_path(),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
],
];
`
from laravel-sftp.
`try {
$validator = Validator::make($request->all(), [
'tipo' => 'required',
'publicacao' => 'required',
'descricao' => 'required',
'exercicio' => 'required',
'arquivo' => 'required|max:300000|mimes:pdf,application/octet-stream'
]);
if ($validator->fails()) {
$response[0] = 'error';
$response[1] = '';
$messages = $validator->errors();
foreach ($messages->all('<li>:message</li>') as $message) {
$response[1] .= $message;
}
return redirect()->back()->with('error', $response[1]);
} else {
if ($request->file('arquivo')->isValid()) {
$arquivo = new Arquivos();
$arquivo->tipo = $request->tipo;
$arquivo->descricao = $request->descricao;
$arquivo->exercicio = $request->exercicio;
$arquivo->publicacao = $request->publicacao;
$file = $request->file('arquivo');
if (!Storage::disk('sftp')->exists(env('MUNICIPIO').'/'.$request->tipo)) {
Storage::makeDirectory(env('MUNICIPIO').'/'.$request->tipo);
}
$microtime = round(microtime(true) * 1000);
$extension = $file->getClientOriginalExtension();
try {
Storage::disk('sftp')->put(env('MUNICIPIO').'/'.$request->tipo . "/" . $microtime . "_" . $request->exercicio . '.' . $extension, File::get($file));
} catch (Exception $e) {
throw $e;
}
if (Storage::disk('sftp')->has(env('MUNICIPIO').'/'.$request->tipo . "/" . $microtime . "_" . $request->exercicio . '.' . $extension)) {
$arquivo->url = '?m='.env('MUNICIPIO').'&p='.$request->tipo . "&f=" . $microtime . "_" . $request->exercicio . '.' . $extension;
if ($arquivo->save()) {
$arquivo->url=$arquivo->url."&i=".($arquivo->id*2);
$arquivo->save();
$response[0] = 'success';
$response[1] = 'Arquivo enviado com sucesso';
} else {
Storage::delete(env('MUNICIPIO').'/'.$request->tipo . "/" . $microtime . "_" . $request->exercicio . '.' . $extension);
$response[0] = 'error';
$response[1] = 'O arquivo não pôde ser enviado, tente mais tarde ou contate o administrador';
}
} else {
$response[0] = 'error';
$response[1] = 'Não foi possível salvar o arquivo, contate o suporte';
}
} else {
$response[0] = 'error';
$response[1] = 'Arquivo inválido';
}
}
return redirect()->back()->with('success', $response[1]);
} catch (\Exception $e) {
Log::info('EXCEPTION AO ENVIAR ARQUIVO ' . $e->getFile() . ' Linha: ' . $e->getLine() . ' ' . $e->getMessage());
}`
it's showing this last exception
from laravel-sftp.
You have to define at least your host, username and password in the SFTP configuration. Do you left your configuration blank or is it in you .env
file ?
In this second case, is there the right data in it ?
from laravel-sftp.
1 - all data defined in .env
2 - yes,
when it shows the exception appear the correct data, signs this is getting it in .env file
from laravel-sftp.
Hum... I can't imagine that a bug in the package could cause this exception. Your configuration looks a little bit odd with the host 000.000.000.000
.
The issue should come from your configuration or a bug in the Flysystem driver (https://github.com/thephpleague/flysystem-sftp). You can try an issue in this package. In fact, the package laravel-sftp
is just a service provider that encapsulate this driver.
from laravel-sftp.
did
composer require league/flysystem-sftp
but nothing changes
the ip not is 000.000.000, was an example.
from laravel-sftp.
did
composer require league/flysystem-sftp
but nothing changesthe ip not is 000.000.000, was an example.
remove or comment the port line in the config
from laravel-sftp.
Related Issues (4)
- Deleted
- downloading HOT 1
- conflict with Laravel 5.6 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-sftp.