- Descripción breve
- Setting up DigitalOcean Spaces for XenForo 2.1+ video uploads simplifies remote file storage, ensuring smooth integration with Flysystem. This guide walks you through setting up DigitalOcean Spaces and configuring XF to use it, including creating API credentials and adjusting XF's config.php for optimal performance. For those preferring Amazon S3, the process is similar but skips DigitalOcean Spaces setup.
Compatibilidad de XenForo VersiónLa descarga solo es compatible con XenForo 2.1 y versiones superiores.¿Por qué este guía?Desde XenForo 2.0.0 hemos soportado el almacenamiento de archivos remotos utilizandoabstracted file system named Flysystem. Se llama un sistema de archivos abstractado ya que añade una capa de abstracción entre el código y un sistema de archivos. Esto significa que proporciona una API consistente para realizar operaciones de sistema de archivos, de manera que, independientemente de si el sistema de archivos es local basado en disco o uno distribuido y accesible remotamente, nuestro código llama a las mismas funciones y Flysystem se encarga del resto.
As útil que eso sea, no es la cosa más obvia ni más sencilla de configurar, por lo que este guía y el complemento que acompaña te ayudará.[URL='https://xenforo.com/community/threads/unfurling-urls-emoji-enhancements-and-video-uploads.154986/post-1289243']video uploads functionEn XF 2.1 o superior y estés preocupado por las necesidades aumentadas de espacio en disco, esto te ayudará.Hacer disponibles los archivos requeridosAunque es posible que descargues los archivos y configures cosas como el cargador automático tú mismo, probablemente prefieras simplemente descargar el addon que está adjunto a este recurso. Puedesinstall the add-on in the usual fashion.Antes de comenzarSi estás configurando esto en un sitio existente, tendrás que mover los archivos existentes manualmente. Hay una sección sobre eso al final. Mientras mueves los archivos existentes, configuras y pruebas, te recomendamos cerrar el foro primero.Configuración de DigitalOcean SpacesLo cubriremos primero ya que es el más sencillo de configurar. Si prefieres usar Amazon S3, adelántate al paso 2.Configuración de Amazon S3sección debajo.
[Ir alDigitalOcean Cloudpágina y regístrate o inicia sesión.[*]En este punto, si eres nuevo en DigitalOcean, podrías necesitar configurar el pago.[¡Ahora podrá crear un nuevo proyecto.
Ahora que está creado el espacio, debería tener un URL de destino, similar a:https://xftest.ams3.digitaloceanspaces.comNota esto para más tarde.
Ahora necesitamos crear algunas credenciales de API. Para hacer esto:
[*Clic "Administrar" en el menú lateral izquierdo.*[*Clic "API".[*.
Este les dará un clave y una secreto. Notenlos.Configurando XF para usar DigitalOcean Spaces$s3 = function() { return new \Aws\S3\S3Client([credenciales[key' => 'ABC',
'secret' => '123',
'region' => 'ams3',
'version' => 'latest',
'endpoint' =>https://ams3.digitaloceanspaces.com, NI ALGÚN OTRO DELIMITADOR.
4. MANTEN LOS NOMBRES PROPIOS (NOMBRÉS DE MARCA, PRODUCTOS) EN SU FORMA ORIGINAL CUANDO ES APPROPRIADO.
Next we need to set up the actual Flysystem adapter to use the S3 client:
PHP: CRITICAS INSTRUCCIONES:
1. SOLO SALIDA LA TRANSLACIón. NO LLAVES, NI CORCHETES, NI BLOQUES DE FORMATEO.
2. NEVERA AGREGAR NOTAS, EJPLANCHOS O FRASES INTRODUCTORIAS.
3. NO ENCADERNE LA SALIDA CON <>, ['data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'data');
};
Finalmente, es necesario asegurar que las URLs de los avatares y las miniaturas de adjuntos estén precedidas con la URL correcta. Esto requiere el URL de endpoint que notas anteriormente:
PHP:
$config[externalDataUrl'] = function($externalPath, $canonical)
{
returnhttps://xftest.ams3.digitaloceanspaces.com/data/' . $externalPath;
};
At this point, everything should be working in terms of new uploads. Don't be alarmed if you notice that avatars and thumbnails are missing; if you have existing files, they will need to be moved over manually which we'll go through later.
First, we need to test that the configuration works. Simply go and upload a new avatar. The avatar will now be stored and served remotely!
If you check your DigitalOcean Spaces account now, you should see that new folders have been created containing your new avatar:
¡Éxito! Pero solo estamos a la mitad del camino.
Ahora necesitamos agregar soporte para el directorio internal_data. Generalmente, esto son adjuntos y cualquier otro tipo de cosas que deberían ser "privadas". Volver al config.php y el código para agregar es muy similar:
PHP:
$config[fsAdapters['internal-data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'internal_data');
};
Now try to upload an attachment to a post and, much like before, you should now see additional files and folders in your Spaces file browser. ?Configuración de Amazon S3
AWS Management Console[/URL]página y regístrate o inicia sesión.[*[*Clic "Crear contenedor".Elige un nombre de usuario (vale, use repetí con xftest ?).*Para establecer permisos, haga clic en la pestaña "Adjuntar políticas existentes directamente" y luego en el botón "Crear política".[*]IAM y las diversas políticas y permisos pueden ser bastante intimidantes. Podemos hacerlo un poco más fácil, aunque puedan tener diferentes requerimientos. En esta página hay una pestaña llamada "JSON". Copie lo siguiente y reemplace YOUR-BUCKET-NAME con el nombre del bucket que eligieron anteriormente:[/list]
Versión[Permitir["s3:ListBucket",
"s3:GetObject",
"s3:GetObjectAcl",
"s3😛utObject",
"s3😛utObjectAcl",
"s3:ReplicateObject",
"s3😀eleteObject"
],["arn:aws:s3:::YOUR-BUCKET-NAME",
"arn:aws:s3:::YOUR-BUCKET-NAME/*"
]
As útil que eso sea, no es la cosa más obvia ni más sencilla de configurar, por lo que este guía y el complemento que acompaña te ayudará.[URL='https://xenforo.com/community/threads/unfurling-urls-emoji-enhancements-and-video-uploads.154986/post-1289243']video uploads functionEn XF 2.1 o superior y estés preocupado por las necesidades aumentadas de espacio en disco, esto te ayudará.Hacer disponibles los archivos requeridosAunque es posible que descargues los archivos y configures cosas como el cargador automático tú mismo, probablemente prefieras simplemente descargar el addon que está adjunto a este recurso. Puedesinstall the add-on in the usual fashion.Antes de comenzarSi estás configurando esto en un sitio existente, tendrás que mover los archivos existentes manualmente. Hay una sección sobre eso al final. Mientras mueves los archivos existentes, configuras y pruebas, te recomendamos cerrar el foro primero.Configuración de DigitalOcean SpacesLo cubriremos primero ya que es el más sencillo de configurar. Si prefieres usar Amazon S3, adelántate al paso 2.Configuración de Amazon S3sección debajo.
[Ir alDigitalOcean Cloudpágina y regístrate o inicia sesión.[*]En este punto, si eres nuevo en DigitalOcean, podrías necesitar configurar el pago.[¡Ahora podrá crear un nuevo proyecto.
Ahora que está creado el espacio, debería tener un URL de destino, similar a:https://xftest.ams3.digitaloceanspaces.comNota esto para más tarde.
Ahora necesitamos crear algunas credenciales de API. Para hacer esto:
[*Clic "Administrar" en el menú lateral izquierdo.*[*Clic "API".[*.
Este les dará un clave y una secreto. Notenlos.Configurando XF para usar DigitalOcean Spaces$s3 = function() { return new \Aws\S3\S3Client([credenciales[key' => 'ABC',
'secret' => '123',
'region' => 'ams3',
'version' => 'latest',
'endpoint' =>https://ams3.digitaloceanspaces.com, NI ALGÚN OTRO DELIMITADOR.
4. MANTEN LOS NOMBRES PROPIOS (NOMBRÉS DE MARCA, PRODUCTOS) EN SU FORMA ORIGINAL CUANDO ES APPROPRIADO.
Next we need to set up the actual Flysystem adapter to use the S3 client:
PHP: CRITICAS INSTRUCCIONES:
1. SOLO SALIDA LA TRANSLACIón. NO LLAVES, NI CORCHETES, NI BLOQUES DE FORMATEO.
2. NEVERA AGREGAR NOTAS, EJPLANCHOS O FRASES INTRODUCTORIAS.
3. NO ENCADERNE LA SALIDA CON <>, ['data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'data');
};
Finalmente, es necesario asegurar que las URLs de los avatares y las miniaturas de adjuntos estén precedidas con la URL correcta. Esto requiere el URL de endpoint que notas anteriormente:
PHP:
$config[externalDataUrl'] = function($externalPath, $canonical)
{
returnhttps://xftest.ams3.digitaloceanspaces.com/data/' . $externalPath;
};
At this point, everything should be working in terms of new uploads. Don't be alarmed if you notice that avatars and thumbnails are missing; if you have existing files, they will need to be moved over manually which we'll go through later.
First, we need to test that the configuration works. Simply go and upload a new avatar. The avatar will now be stored and served remotely!
If you check your DigitalOcean Spaces account now, you should see that new folders have been created containing your new avatar:
Ahora necesitamos agregar soporte para el directorio internal_data. Generalmente, esto son adjuntos y cualquier otro tipo de cosas que deberían ser "privadas". Volver al config.php y el código para agregar es muy similar:
PHP:
$config[fsAdapters['internal-data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'internal_data');
};
Now try to upload an attachment to a post and, much like before, you should now see additional files and folders in your Spaces file browser. ?Configuración de Amazon S3
AWS Management Console[/URL]página y regístrate o inicia sesión.[*[*Clic "Crear contenedor".Elige un nombre de usuario (vale, use repetí con xftest ?).*Para establecer permisos, haga clic en la pestaña "Adjuntar políticas existentes directamente" y luego en el botón "Crear política".[*]IAM y las diversas políticas y permisos pueden ser bastante intimidantes. Podemos hacerlo un poco más fácil, aunque puedan tener diferentes requerimientos. En esta página hay una pestaña llamada "JSON". Copie lo siguiente y reemplace YOUR-BUCKET-NAME con el nombre del bucket que eligieron anteriormente:[/list]
Versión[Permitir["s3:ListBucket",
"s3:GetObject",
"s3:GetObjectAcl",
"s3😛utObject",
"s3😛utObjectAcl",
"s3:ReplicateObject",
"s3😀eleteObject"
],["arn:aws:s3:::YOUR-BUCKET-NAME",
"arn:aws:s3:::YOUR-BUCKET-NAME/*"
]
Este les dará un clave y una secreto. Anoteles.Configurando XF para usar Amazon S3$s3 = function() { return new \Aws\S3\S3Client([credenciales[key' => 'ABC',
'secret' => '123',
'region' => 'eu-west-2',
'version' => 'latest',
'endpoint' =>https://s3.eu-west-2.amazonaws.comConfiguración de la clave y secreto como los que anotaste después de configurar el usuario IAM anteriormente. La región puede inferirse del URL del punto final S3.
Ahora necesitamos establecer realmente el adaptador de Flysystem para usar con el cliente S3:
PHP: Configuración['data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'data');
};
Finally, we need to ensure that avatar and attachment thumbnail URLs are prepended with the correct URL:
PHP:
$config[externalDataUrl'] = function($externalPath, $canonical)
{
returnhttps://xftest.s3.eu-west-2.amazonaws.com/data/' . $externalPath;
};
At this point, everything should be working in terms of new uploads. Don't be alarmed if you notice that avatars and thumbnails are missing; if you have existing files, they will need to be moved over manually which we'll go through later.
First, we need to test that the configuration works. Simply go and upload a new avatar. The avatar will now be stored and served remotely!
If you check your bucket file browser now, you should see that new folders have been created containing your new avatar:¡Éxito! Pero solo hemos llegado al medio camino.
Ahora necesitamos agregar soporte para el directorio internal_data también. Generalmente, esto son adjuntos y cualquier otro tipo de "privado". Volver a config.php y la parte de código que necesita añadirse es muy similar:
PHP:
$config['internal-data'] = function() use($s3) {
return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'xftest', 'internal_data');
};
Now try to upload an attachment to a post and, much like before, you should now see additional files and folders in your bucket file browser. ?Moviendo archivos existentes a Spaces DigitalOcean o Amazon S3Hay, ahora tienes archivos remotamente alojados. Desde este punto en adelante. Pero ¿qué pasa con todos los archivos que ya tienes?
Afortunadamente, existen varias formas de interactuar con Spaces y S3 para hacer la migración de tu contenido actual muy fácilmente. Aunque esta operación es una vez por todas, dependiendo del número y tamaño de los archivos, podría tomar un tiempo significativo.
Hay algunas formas de gestionar este proceso, pero sin duda el enfoque mejor es usar un herramienta llamadas3cmdqué es un popular herramienta de línea de comandos multiplataforma para gestionar S3 y almacenes de objetos compatibles con S3.
Es posible instalar la herramienta s3cmd en tu servidor tanto si usas Spaces como S3 e ejecutar los comandos necesarios para copiar los archivos a su nuevo hogar.
En lugar de repetir algo que ya ha sido escrito, te dejaré con el siguiente guía de DigitalOcean que explica cómo migrar tus archivos existentes utilizando s3cmd.
s3cmd 2.x Setup :: DigitalOcean Product Documentation
s3cmd es un popular herramienta de línea de comandos cross-platform para gestionar bases de objetos S3 y compatibles con S3. Para usar s3cmd, necesitarás: la versión 2.0.0+ o superior de s3cmd. Puedes verificar tu versión con s3cmd --version. Las versiones de paquetes pueden estar desactualizadas, por lo que recomendamos usar la s3cmd...www.digitalocean.comNota:Cuando copias tus archivos de datos existentes, tendrás que hacerlos públicos. Puedes hacer esto estableciendo el ACL a público mientras estés copiando:
Examples of s3cmd 2.x Usage with DigitalOcean Spaces :: DigitalOcean Documentation
Ejemplos de comandos s3cmd para acciones comunes con Spaces, como subir y gestionar archivos, establecer permisos y encriptación.www.digitalocean.com