我需要使用BinaryFileResponseLength Headers 和 co 来正确处理视频。我还希望用户允许配置其他存储(S3、Dropbox)。flysystemreadStream方法将返回一个resource但BinaryFileResponse需要一个string路径。处理这个问题的最佳方法是什么?首先将整个文件下载到服务器直到响应?
我是第一次使用Flysystem使用 S3(在这种情况下特别是用户配置文件头像图像)实现文件上传。我目前正处于创建 S3 存储桶的阶段,用户可以上传图像,然后可以在存储桶控制台中在线查看该图像。
我现在需要能够在请求时显示这些图像(即查看该用户的个人资料)。我假设此过程将生成 URL(例如https://s3.my-region.amazonaws.com/my-bucket/my-filename.jpeg)并将其用作src图像标签的这样做,文件(或存储桶)必须标记为公共。这对我来说似乎是合理的,因为其中的文件并不是真正私密的。但是,当将存储桶更新为公共状态时,您会看到一条消息,说明;
我们强烈建议您永远不要授予对 S3 存储桶的任何类型的公共访问权限。
是否有不同或更安全的方式来实现这样的直接图像链接,而 AWS 的新手没有看到?
根据Flysystem 的配置,我在 config.yml 中进行了以下设置:
oneup_flysystem:
adapters:
acme.flysystem_adapter:
awss3v3:
client: acme.s3_client
bucket: "%s3_bucket_name%"
prefix: "symfotest_"
Run Code Online (Sandbox Code Playgroud)
我在 services.yml 上提供了以下设置:
acme.s3_client:
class: Aws\S3\S3Client
arguments:
-
version: 'latest' # or 'latest'
region: "%s3_region%" # 'eu-central-1' for example
credentials:
key: "%s3_key%"
secret: "%s3_secret%"
Run Code Online (Sandbox Code Playgroud)
最后我通过 SetEnv 设置了以下环境变量:
SetEnv SYMFONY_S3_BUCKET_NAME symphotest
SetEnv SYMFONY_S3_REGION eu_west_1
SetEnv SYMFONY_S3_KEY akey
SetEnv SYMFONY_S3_SECRET asuperseccret
Run Code Online (Sandbox Code Playgroud)
但我的 error.log 中出现以下错误:
[Wed Jul 06 21:11:56.424801 2016] [:error] [pid 21876] [client 127.0.0.1:60488] PHP 致命错误:未捕获的 Symfony\Component\DependencyInjection\Exception\InvalidArgumentException:没有扩展能够加载“oneup_flysystem”的配置(在 /home/pcmagas/Kwdikas/web/apps/symphotest/app/config/config.yml 中)。查找命名空间“oneup_flysystem”,在 /home/pcmagas/Kwdikas/web/apps/symphotest/vendor 中找到“framework”、“security”、“twig”、“monolog”、“swiftmailer”、“doctrine”、“sensio_framework_extra” /symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php:368\n堆栈跟踪:\n#0 /home/pcmagas/Kwdikas/web/apps/symphotest/vendor/symfony/symfony/src/Symfony /Component/DependencyInjection/Loader/YamlFileLoader.php(338): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->validate(Array, '/home/pcmagas/K...')\n#1 …
我在一个存储桶中有对象,我偶尔需要将这些对象传输到 Amazon S3 中的第二个存储桶。我正在使用带有 Flysystem 的 Laravel 5.3 来管理这些存储桶。
一种解决方案是将图像下载到我的服务器,然后将其上传到另一个存储桶,但这似乎是浪费时间/带宽,因为该文件存在于 S3 中并且正在 S3 中移动。这可以在 Flysystem 内完成还是我需要直接使用亚马逊的 API?
我正在尝试将文件从临时路径移动到正确的路径。但是,无论我尝试什么,它总是发回此文件未找到错误:
League\Flysystem\FileNotFoundException
File not found at path: var/www/html/storage/app/public/covers/tmp/608c07a082451-1619789728/81-536x354.jpeg
Run Code Online (Sandbox Code Playgroud)
我正在使用 sail,因此路径中有 'var/www/html/',即使容器中的此路径没有问题,因为可以从前端获取 API 到达此路径,这就是 temp 的方式文件已保存。
这是控制器中的代码:
//...
$temp_file = TempFile::where('folder', $cover_folder)->first();
if ($temp_file) {
// retrieve file path and target path
$filepath = storage_path("app/public/covers/tmp/{$temp_file->folder}/{$temp_file->filename}");
$target_path = storage_path("app/public/covers/{$course->id}/");
Storage::move($filepath, $target_path);
$course->cover_img = "{$target_path}/{$temp_file->filename}";
$course->save();
// remove temp directory and temp file record
rmdir(storage_path("app/public/covers/tmp/{$temp_file->folder}/"));
$temp_file->delete();
}
Run Code Online (Sandbox Code Playgroud)
此行突出显示的错误回溯:
Storage::move($filepath, $target_path);
Run Code Online (Sandbox Code Playgroud)
还尝试使用Storage::disk('public')->move()、 或 、public_storage或Storage::path()、 或仅纯字符串,但均无效。
通过运行将符号链接设置为从public/storage到。storagephp artisan storage:link
我在 laracast、stackoverflow 或 github 上进行了尽可能多的搜索,但无法找到解决方案。有人对这个问题有任何想法吗?
真的真的很感激。
laravel 框架是 7.9.2。
composer 需要安装 League/flysystem-aws-s3-v3 ~1.0 才能使用 aws s3。
它在本地主机上运行,但是当我将它放在 aws 服务器上时,
错误:出现 Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found 错误。
但是,当我检查作曲家许可证时,
它被标识为 League/flysystem v1.0.67 MIT。
我不知道是什么问题。如果你有和我一样的困难,请帮助我。
我正在尝试使用和将一些文件s3从 digitalocean (空间)上传到兼容存储。Laravel 8flysystem-aws-s3-v3
但是当我提交这些文件时,我收到此错误:
Aws\S3\Exception\S3Exception
Error executing "PutObject" on "//SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com"; AWS HTTP error: Server error: `PUT http://SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com` resulted in a `501 Not Implemented` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-00605636a9-96 (truncated...) NotImplemented (server): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-0060
Run Code Online (Sandbox Code Playgroud)
5636a9-9617be5-nyc3c9617be5-nyc3c-nyc3-zg03
这是我的 digitalocean 常量.env:
DO_SPACES_ACCESS_KEY=[edit]
DO_SPACES_SECRET_ACCESS_KEY=[edit]
DO_SPACES_ENDPOINT=nyc3.digitaloceanspaces.com
DO_SPACES_REGION=nyc3
DO_SPACES_BUCKET=SPACES_NAME
DO_URL=https://SPACES_NAME.nyc3.cdn.digitaloceanspaces.com
Run Code Online (Sandbox Code Playgroud)
这是来自的配置部分config/filesystem.php:
'disks' => [
...
'do' => [
'driver' => 's3',
'key' => env('DO_SPACES_ACCESS_KEY'),
'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'url' …Run Code Online (Sandbox Code Playgroud) flysystem ×7
php ×5
laravel ×4
amazon-s3 ×3
symfony ×2
file-upload ×1
laravel-5.3 ×1
laravel-8 ×1