A sentence right in your question hints at why this is a conundrum:
File storage is a generic subdomain, while accounting is a core domain.
There appears to be a misconception about what constitutes a "software layer." Layers are not defined by where you put a class. Software layers are defined by what those classes are primarily concerned with. The answer to the existential question "why do I exist?" is the primary motivator for grouping classes together in a layer. If a group of classes exist for the same basic purpose, then they could go in the same layer[1].
In your diagram, the File Storage Service is correctly associated with the infrastructure layer. The infrastructure layer is primarily concerned with interfacing with services and resources outside the control of your application. The file system is a perfect example of this.
The accounting service, which you describe as a "core domain", is primarily concerned with business logic, not file storage. As such, the Accounting Service does not belong to the infrastructure layer. The Accounting Service belongs in some application-related layer. The accounting service depends on the file storage service. Typically this dependency is represented by an interface to allow for mocking when writing unit tests.
Be aware that Domain-Driven Design is not an application architecture — it is a design philosophy. DDD does not specify where the File Storage Service and Accounting Service classes should go. This level of detail is captured in an application architecture, like Onion Architecture, Clean Architecture, etc. DDD helps you organize business logic as a means to manage complexity. One way you accomplish this is by removing data storage logic from your core businesses classes.
Many application architectures have an "infrastructure" layer, because this separation is desirable in general, not just with Domain-Driven Design. DDD does not prescribe exactly where the accounting service should go. This is driven by application architecture, not some business logic design philosophy.
Your question arises from organizing and grouping classes incorrectly. The accounting service, which is primarily concerned with business logic and coordination, is not an infrastructure class. The accounting service belongs in a different layer that depends on the infrastructure layer. This resolves your question because you no longer need inversion of control within the same layer. The file storage and accounting services reside in different layers.
The layer containing the accounting service should define an interface for file storage that is implemented by the real file storage service in the infrastructure layer. This follows the Dependency Inversion principal (the "D" in "SOLID"). Dependencies across modules should rely on abstractions. Interfaces and abstract classes are some of the most common abstractions used at the boundaries between application modules.
- On a technical level, classes are often grouped into layers based on their dependencies, but I would argue that dependencies are discovered after answering the existential question: "why do I exist?" Only after discovering why a class exists can you identify the other objects it must collaborate with to fulfill its primary purpose in the application, and therefore which layer it belongs to.