手机做ppt免费模板_珠海网站建设方案外包_最新足球新闻头条_申请域名
2025/2/22 15:50:40
来源:https://blog.csdn.net/yanlinpu/article/details/144251744
浏览:
次
关键词:手机做ppt免费模板_珠海网站建设方案外包_最新足球新闻头条_申请域名
手机做ppt免费模板_珠海网站建设方案外包_最新足球新闻头条_申请域名
rails console 调试
- 查看配置
Settings.uploads.object_store
- 加载minio client
require 'fog/aws'fog_connection = Fog::Storage.new(provider: 'AWS',aws_access_key_id: '你的MINIO_ACCESS_KEY',aws_secret_access_key: '你的MINIO_SECRET_KEY',region: '<S3 region>',endpoint: 'http://127.0.0.2:7480',path_style: true # 需要开启 path_style
)bucket = fog_connection.directories.get('你的BUCKET_NAME')
- 创建测试文件
require 'tempfile'temp_file = Tempfile.new(['test_upload', '.txt'])
temp_file.write('这是一个测试文件内容')
temp_file.rewind # 将文件指针移到开头
- 模拟上传到minio
bucket.files.create(key: file_path,body: temp_file.read,public: false
)
- 获取文件
uploaded_file = bucket.files.get(file_path)
uploaded_file.key
uploaded_file.body
- 删除文件
uploaded_file.destroy
- Giltab上传
uploader = FileUploader.new
uploader.store!(temp_file)puts "上传路径: #{uploader.url}"
注意事项
path_style: true
# Use ‘host/bucket_name/object’ instead of ‘bucket_name.host/object’proxy_download: false
# Passthrough all downloads via GitLab instead of using Redirects to Object Storage