Skip to content

Commit

Permalink
Merge pull request #22 from itk-dev/feature/file-name-normalization
Browse files Browse the repository at this point in the history
Normalized file name for Windows
  • Loading branch information
rimi-itk authored Dec 15, 2023
2 parents 755927f + 93c455f commit 3605343
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GetOrganized API client
# GetOrganized API client

## Installation

Expand Down Expand Up @@ -56,11 +56,31 @@ class Tiles extends Service

## Development

### Tests

```sh
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest vendor/bin/phpunit
```

### Coding standards

The following commands let you test that the coding standards:
The following commands let you test that the code adheres to the coding standards:

```sh
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer coding-standards-check
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check
```

Automatically fix some coding standards issues by running

```sh
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply
```

### Code analysis

```sh
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer code-analysis
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CaseId: 'GEO-2022-000114'
ListName: 'Dokumenter'
FolderPath: ''
FileName: ''
FileName: 'pipfugl.png'
Metadata: '<z:row xmlns:z="#RowsetSchema"/>'
Overwrite: true
response:
Expand Down
8 changes: 8 additions & 0 deletions src/Service/Documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function AddToDocumentLibrary(string $filePath, string $caseId, string $f

$bytes = self::fileToIntArray($filePath);

if (empty($fileName)) {
$fileName = basename($filePath);
}

// Make sure that the file name is valid in Windows (cf.
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions).
$fileName = preg_replace('@[<>:"/\\\\|?*]@', '_', $fileName);

$result = $this->getData(
'POST',
$this->getApiBasePath().__FUNCTION__,
Expand Down

0 comments on commit 3605343

Please sign in to comment.