Version: latest
The SFTP integration in AS2Gateway relies on a certain folder structure to identify AS2 Stations and Partners when sending files through SFTP and when storing received file to the SFTP folder. In this section we will try to understand what this folder structure is.
Let’s start with the following sample SFTP folder structure.
As you can see in the above image, there are two directories in the top level. If you login to the SFTP server, you will see the same structure in the top level.
.ssh
as2gateway
The .ssh
folder includes configuration files related to your SFTP login and users will not need to do any changes on
that path. The folder as2gateway
on the other hand is the one we should look into.
as2gateway
Inside the as2gateway
folder, you will see zero to multiple folders depending on your AS2 Station configuration. If
you have AS2 Stations created, you will see a folder for each AS2 station with the AS2 identifier used as the name of the
folder. In the example above there are two folders for my two AS2 Stations with AS2 identifiers RJ_ONE
and PT
.
As another example, if you have stations alice
, bob
and partners AMZN
, WLMRT
,
you will have the following subpaths inside as2gateway
:
alice/AMZN
alice/WLMRT
bob/AMZN
bob/WLMRT
Now let’s look into the next level in the folder structure. What you see in this level are folders for each of your
AS2 partners (using the partners' AS2 identifiers as the folder names). Under each AS2 Station directory, a folder is there
for each of your partners. If you look at the example structure shown above, in this case I have only one AS2 partner with
the identifier DemoAS2
and you will notice that there is a folder by the name DemoAS2
under both of my Station
folders PT
and RJ_ONE
.
Moving on to the next level, you will notice that under each AS2 partner folder, there are three folders as follows.
failed
inbox
outbox
outbox
Out of these the most important two are the inbox
folder and the outbox
folder.
If you want to send a file to a trading partner from a certain AS2 Station,
then you should copy the file you want to sent to that relevant outbox folder.
For an instance taking the above folder structure as a sample, say we want to send a file to DemoAS2
trading partner from
the RJ_ONE
AS2 station, then the path to which we should copy the file would be as2gateway/RJ_ONE/DemoAS2/outbox
.
So the general path to which you want to copy a file when you want to send a file via AS2 would be as follows.
as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/outbox
inbox
Now let’s talk about the inbox
folder.
The outbox folder was all about sending messages out and as the name suggests the inbox
folder is all about the incoming AS2 messages.
As per the same sample folder structure which we have been looking at before,
if we receive a file from DemoAS2
partner to RJ_ONE
partner, the path which that file will be stored would be
as2gateway/RJ_ONE/DemoAS2/inbox
. So if we generalize that path, it would be something as follows.
as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/inbox
You can control the path/folder structure where AS2 Gateway saves incoming files, via the Folder Structure option under your trading station:
Files for each incoming message will be saved into its own timestamp-prefixed subdirectory; i.e. under the subfolder structure:
<root dir>/ | |__as2gateway/ | |__<station ID>/ | |__<partner ID>/ | |__inbox/ | |__<message processed timestamp>-<random number>/ | |__<original attachment filename>
E.g. for an invoce.edi
from a message received at 2019-11-13 10:23:34.297:
as2gateway/MY_STATION/MY_PARTNER/inbox/20191113102334297-859863/invoice.edi
In this case, there will be no per-message subfolder;
instead, everything will be saved in inbox
itself,
with a timestamp-based unique prefix being prepended to the original attachment filename:
<root dir>/ | |__as2gateway/ | |__<station ID>/ | |__<partner ID>/ | |__inbox/ | |__<message processed timestamp>-<random number>-<original attachment filename>
E.g. for an invoce.edi
from a message received at 2019-11-13 10:23:34.297:
as2gateway/MY_STATION/MY_PARTNER/inbox/20191113102334297-859863-invoice.edi
In this case, files will be saved directly in inbox
using the original filename, without any prefix or subfolder.
If your partner sends multiple files with the same name, newly received files may overwrite older files; and only the latest file will remain.
However this is usually not an issue, because many partner systems use a unique prefix/suffix on each filename.
<root dir>/ | |__as2gateway/ | |__<station ID>/ | |__<partner ID>/ | |__inbox/ | |__<original attachment filename>
E.g. for an invoce.edi
from a message received at 2019-11-13 10:23:34.297:
as2gateway/MY_STATION/MY_PARTNER/inbox/invoice.edi
failed
failed
folder will contain attachments that have been picked from outbox
,
but for some reason could not be enqueued for sending.
If you find any files here and do not have a proper explanation regarding why the file failed,
contact AS2 Gateway Team and ask for an explanation.
If your trading partner is of type test (selectable at partner creation),
the message folders (inbox
etc.) will be nested inside another folder level test
.
So if you have a test partner ALIBB
, its folders under station alice
would be
as2gateway/alice/ALIBB/test/inbox
as2gateway/alice/ALIBB/test/outbox
as2gateway/alice/ALIBB/test/error
If you also have defined a production partner with the same ID, ALIBB
subfolder will contain the usual inbox
etc.
(for holding usual production data), in addition to the test
subpath:
as2gateway/alice/ALIBB/inbox
as2gateway/alice/ALIBB/outbox
as2gateway/alice/ALIBB/error
as2gateway/alice/ALIBB/test/inbox
as2gateway/alice/ALIBB/test/outbox
as2gateway/alice/ALIBB/test/error