-
-
Notifications
You must be signed in to change notification settings - Fork 6
i18n(fr): translate files in storage-api
#202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dreyfus92
merged 2 commits into
withstudiocms:main
from
ArmandPhilippot:i18n/fr-add-storage-api
Jan 23, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| --- | ||
| i18nReady: true | ||
| title: Point de terminaison de l'API | ||
| description: Découvrez les points de terminaison de l'API disponibles dans l'API de stockage de StudioCMS. | ||
| tableOfContents: | ||
| minHeadingLevel: 2 | ||
| maxHeadingLevel: 4 | ||
| sidebar: | ||
| order: 3 | ||
| badge: | ||
| text: NOUVEAU | ||
| variant: success | ||
| --- | ||
|
|
||
| import ReadMore from '~/components/ReadMore.astro'; | ||
| import { Aside } from '@astrojs/starlight/components'; | ||
|
|
||
| L'API de stockage expose des points de terminaison accessibles via des requêtes HTTP. Les sections suivantes décrivent les points de terminaison disponibles et leur utilisation. | ||
|
|
||
| <Aside type="note" title="Utilise locals pour l'autorisation"> | ||
| Les points de terminaison de l'API de stockage utilisent la fonctionnalité `locals` d'Astro, propagée par le middleware, pour gérer l'autorisation. Assurez-vous que le navigateur ou le client effectuant les requêtes provient d'un utilisateur StudioCMS connecté et disposant des autorisations nécessaires pour effectuer des opérations de stockage. | ||
| </Aside> | ||
|
|
||
| ### Méthode : PUT | ||
|
|
||
| Pour télécharger ou mettre à jour un fichier dans le système de stockage, vous pouvez utiliser la méthode `PUT` dans le point de terminaison `/studiocms_api/storage/manager`. | ||
|
|
||
| ```http title="API de stockage - PUT /studiocms_api/storage/manager" | ||
| PUT /studiocms_api/storage/manager HTTP/1.1 | ||
| Host: example.com | ||
| Content-Type: application/octet-stream | ||
| Accept: application/json | ||
| Headers: | ||
| x-storage-key: my-file.txt | ||
|
|
||
| <file-content> | ||
| ``` | ||
|
|
||
| #### Réponse de succès | ||
|
|
||
| ```http title="API de stockage - PUT Réponse de succès" | ||
| HTTP/1.1 200 OK | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "message": "string", | ||
| "key": "string" | ||
| } | ||
| ``` | ||
|
|
||
| #### Réponse d'erreur | ||
|
|
||
| ```http title="API de stockage - PUT Réponse d'erreur" | ||
| HTTP/1.1 4XX/5XX Error | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "error": "string" | ||
| } | ||
| ``` | ||
|
|
||
| ### Méthode : POST | ||
|
|
||
| ```http title="API de stockage - POST /studiocms_api/storage/manager" | ||
| POST /studiocms_api/storage/manager HTTP/1.1 | ||
| Host: example.com | ||
| Content-Type: application/json | ||
| Accept: application/json | ||
|
|
||
| { | ||
| "action": "resolveUrl | publicUrl | upload | list | delete | rename | download | cleanup | mappings | test", | ||
| ...paramètres supplémentaires reposant sur l'action... | ||
| } | ||
| ``` | ||
|
|
||
| #### Actions | ||
|
|
||
| - `resolveUrl` | ||
| - **Paramètres :** `{ identifier: string }` | ||
| - **Réponse :** [`UrlMetadata`](#urlmetadata) | ||
| - `publicUrl` | ||
| - **Paramètres :** `{ key: string }` | ||
| - **Réponse :** [`UrlMetadata`](#urlmetadata) `& { identifier: string }` | ||
| - `upload` | ||
| - **Paramètres :** `{ key: string, contentType: string }` | ||
| - **Réponse :** `{ url: string, key: string }` | ||
| - `list` | ||
| - **Paramètres :** `{ prefix?: string, key?: string }` | ||
| - **Réponse :** `{ files:` [`File[]`](#file) `}` | ||
| - `delete` | ||
| - **Paramètres :** `{ key: string }` | ||
| - **Réponse :** `{ success: boolean }` | ||
| - `rename` | ||
| - **Paramètres :** `{ key: string, newKey: string }` | ||
| - **Réponse :** `{ success: boolean, newKey: string }` | ||
| - `download` | ||
| - **Paramètres :** `{ key: string }` | ||
| - **Réponse :** `{ url: string }` | ||
| - `cleanup` | ||
| - **Paramètres :** `N/A` | ||
| - **Réponse :** `{ deletedCount: number }` | ||
| - `mappings` | ||
| - **Paramètres :** `N/A` | ||
| - **Réponse :** `{ mappings:` [`UrlMetadata[]`](#urlmetadata) `}` | ||
| - `test` | ||
| - **Paramètres :** `N/A` | ||
| - **Réponse :** `{ success: boolean, message: string, provider: string }` | ||
|
|
||
| #### Réponse d'erreur | ||
|
|
||
| ```http title="API de stockage - POST Réponse d'erreur" | ||
| HTTP/1.1 4XX/5XX Error | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "error": "string" | ||
| } | ||
| ``` | ||
|
|
||
| ## Types | ||
|
|
||
| ### UrlMetadata | ||
|
|
||
| ```ts | ||
| export interface UrlMetadata { | ||
| url: string; | ||
| isPermanent: boolean; | ||
| expiresAt?: number; // Horodatage Unix en ms | ||
| } | ||
| ``` | ||
|
|
||
| ### File | ||
|
|
||
| ```ts | ||
| export interface File { | ||
| key: string | undefined; | ||
| size: number | undefined; | ||
| lastModified: Date | undefined; | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| --- | ||
| i18nReady: true | ||
| title: Vue d'ensemble | ||
| description: Découvrez l'API de stockage de StudioCMS | ||
| tableOfContents: | ||
| minHeadingLevel: 2 | ||
| maxHeadingLevel: 4 | ||
| sidebar: | ||
| order: 1 | ||
| badge: | ||
| text: NOUVEAU | ||
| variant: success | ||
| --- | ||
|
|
||
| import ReadMore from '~/components/ReadMore.astro'; | ||
| import { Aside } from '@astrojs/starlight/components'; | ||
|
|
||
| L'API de stockage de StudioCMS offre une méthode unifiée pour gérer et interagir avec différents systèmes de stockage. Elle simplifie la complexité de ces systèmes, permettant ainsi aux développeurs de travailler avec une interface cohérente quelle que soit la technologie sous-jacente. | ||
|
|
||
| ## Son fonctionnement | ||
|
|
||
| L'API de stockage est conçue pour être flexible et extensible. Elle prend en charge plusieurs systèmes de stockage, notamment les systèmes de fichiers locaux, les services de stockage cloud et les bases de données. Les développeurs peuvent choisir le système de stockage le mieux adapté à leurs besoins et passer facilement de l'un à l'autre sans modifier le code de leur application. | ||
|
|
||
| ## Modules d'extension de gestionnaire | ||
|
|
||
| L'API de stockage utilise des modules d'extension de gestionnaire pour gérer différents systèmes de stockage. Chaque module d'extension de gestionnaire implémente un système de stockage spécifique et fournit des méthodes pour les opérations courantes telles que la lecture, l'écriture et la suppression de fichiers. | ||
|
|
||
| Un exemple de gestionnaire intégré à StudioCMS est le gestionnaire `no-op`, qui n'effectue aucune opération et indique à StudioCMS de ne pas activer ses fonctionnalités de stockage. | ||
|
|
||
| ### Exemple de gestionnaire sans opération | ||
|
|
||
| ```ts twoslash title="NoOpStorageService.ts" | ||
| import type { | ||
| AuthorizationType, | ||
| ContextDriverDefinition, | ||
| StorageAPIEndpointFn, | ||
| StorageApiBuilderDefinition, | ||
| UrlMappingServiceDefinition, | ||
| } from 'studiocms/storage-manager/definitions'; | ||
|
|
||
| /** | ||
| * A No-Op Storage Service that implements the StorageApiBuilderDefinition interface. | ||
| * | ||
| * This service provides placeholder implementations for storage API endpoints, | ||
| * returning a 501 Not Implemented response for both POST and PUT requests. | ||
| * | ||
| * @typeParam C - The context type. | ||
| * @typeParam R - The response type. | ||
| */ | ||
|
ArmandPhilippot marked this conversation as resolved.
|
||
| export default class NoOpStorageService<C, R> implements | ||
| StorageApiBuilderDefinition<C, R> { | ||
| driver: ContextDriverDefinition<C, R>; | ||
| urlMappingService: UrlMappingServiceDefinition; | ||
|
|
||
| constructor( | ||
| driver: ContextDriverDefinition<C, R>, | ||
| urlMappingService: UrlMappingServiceDefinition | ||
| ) { | ||
| this.driver = driver; | ||
| this.urlMappingService = urlMappingService; | ||
| } | ||
|
|
||
| #sharedResponse() { | ||
| return { data: { error: 'noStorageConfigured' }, status: 501 }; | ||
| } | ||
|
|
||
| getPOST(_?: AuthorizationType): StorageAPIEndpointFn<C, R> { | ||
| return this.driver.handleEndpoint(async () => this.#sharedResponse()); | ||
| } | ||
|
|
||
| getPUT(_?: AuthorizationType): StorageAPIEndpointFn<C, R> { | ||
| return this.driver.handleEndpoint(async () => this.#sharedResponse()); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Configuration d'un gestionnaire | ||
|
|
||
| Pour configurer un gestionnaire de stockage dans StudioCMS, vous devez spécifier le module d'extension de gestionnaire souhaité dans votre fichier de configuration StudioCMS. Pour ce faire, vous devez installer le paquet du module d'extension de gestionnaire, puis l'ajouter à la propriété `storageManager` dans votre fichier `studiocms.config.*`. | ||
|
|
||
| ```ts twoslash title="studiocms.config.mjs" {5} | ||
| import { defineStudioCMSConfig } from "studiocms/config"; | ||
| import s3Storage from '@studiocms/s3-storage'; | ||
|
|
||
| export default defineStudioCMSConfig({ | ||
| storageManager: s3Storage(), | ||
| // autres options de configuration | ||
| }) | ||
| ``` | ||
|
|
||
| <ReadMore> | ||
| Pour connaître les modules d'extension de gestionnaire de stockage disponibles, consultez le [catalogue des paquets](/fr/package-catalog#gestionnaires-de-stockage). | ||
| </ReadMore> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| i18nReady: true | ||
| title: Fonctions d'assistance JavaScript | ||
| description: Découvrez les fonctions d'assistance JavaScript disponibles dans l'API de stockage de StudioCMS. | ||
| tableOfContents: | ||
| minHeadingLevel: 2 | ||
| maxHeadingLevel: 4 | ||
| sidebar: | ||
| order: 2 | ||
| badge: | ||
| text: NOUVEAU | ||
| variant: success | ||
| --- | ||
|
|
||
| import ReadMore from '~/components/ReadMore.astro'; | ||
| import { Aside } from '@astrojs/starlight/components'; | ||
|
|
||
| L'API de stockage de StudioCMS fournit plusieurs fonctions d'assistance JavaScript pour faciliter l'interaction avec les systèmes de stockage. Ces fonctions d'assistance simplifient des tâches telles que la résolution des identifiants et des clés de stockage, ainsi que la fourniture de définitions de type pour une sûreté du typage et une complétion de code améliorées. | ||
|
|
||
| ## Fonctions d'assistance JavaScript | ||
|
|
||
| ```ts twoslash title="exemple-api-stockage.ts" | ||
| import { | ||
| resolveStorageIdentifier, | ||
| resolveStorageKey, | ||
| } from 'studiocms/storage-api'; | ||
|
|
||
| const storageIdentifier = await resolveStorageIdentifier('storage-file://my-file.txt', { | ||
| baseUrl: 'https://example.com/', // Utilisez la valeur de `site` depuis "astro:config/server" | ||
| }); | ||
|
|
||
| const storageKey = await resolveStorageKey('my-file.txt', { | ||
| baseUrl: 'https://example.com/', // Utilisez la valeur de `site` depuis "astro:config/server" | ||
| }); | ||
| ``` | ||
|
|
||
| ## Types JavaScript | ||
|
|
||
| ```ts twoslash title="types-api-stockage.ts" | ||
| import type { | ||
| ContextJsonBody, | ||
| AuthorizationType, | ||
| ParsedContext, | ||
| UrlMetadata, | ||
| UrlMapping, | ||
| ContextHandler, | ||
| ContextHandlerFn, | ||
| ContextDriverDefinition, | ||
| StorageAPIEndpointFn, | ||
| StorageApiBuilderDefinition, | ||
| UrlMappingDatabaseDefinition, | ||
| UrlMappingServiceDefinition, | ||
| APICoreDefinition | ||
| } from 'studiocms/storage-api'; | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.