Skip to content

Can't use Import plugin with S3 #15247

@anhdd-kuro

Description

@anhdd-kuro

Describe the Bug

I keep getting this errors when trying to import

  • 403 Error
 GET /api/imports/file/2026-01-16_12_59_28.csv 403 in 141ms

Tried to bypass it with this and it worked for now

 access: {
    read: ({ req }) => true,
  }, 
  • Next 404
 GET /api/imports/file/2026-01-16_12_59_28.csv 404 in 141ms
[14:26:23] ERROR: Failed to queue import job for document 17
    err: {
      "type": "Error",
      "message": "Failed to fetch file from URL: http://localhost:1234/api/imports/file/2026-01-16_12_59_28.csv"

The file is uploaded to S3 by following setting but the job still looking for local files

export const s3Plugin = s3Storage({
  enabled: true,
  signedDownloads: {
    shouldUseSignedURL: () => true,
    expiresIn: 5 * 60, // 5 minutes
  },
  collections: {
    imports: { prefix: 'imports' },
    exports: { prefix: 'exports' },
  },
  bucket: process.env.AWS_S3_BUCKET || '',
  config: {
    region: process.env.AWS_REGION || '',
    credentials: s3Credentials,
  },
})

I can even directly access http://localhost:1234/api/imports/file/2026-01-16_12_59_28.csv to download it.
Why is this happening and how can I solve it?
Here are my current settings.

import { importExportPlugin } from '@payloadcms/plugin-import-export'
import { CollectionConfig, CollectionSlug } from 'payload'

const AllowImportExportCollections: CollectionSlug[] = [
  'users',
  'organizations',
]

export const importExportPluginConfig = importExportPlugin({
  overrideExportCollection: ({ collection }) => {
    const importCustomConfig = {
      upload: {
        disableLocalStorage: true,
      },
      access: {},
      },
      admin: {
        group: 'System',
      },
      labels: {
        singular: {
          ja: 'インポート',
          en: 'Import',
        },
        plural: {
          ja: 'インポート',
          en: 'Imports',
        },
      },
    } satisfies Partial<CollectionConfig>

    if (collection.admin) {
      collection.admin = { ...collection.admin, ...importCustomConfig.admin }
    } else {
      collection.admin = importCustomConfig.admin
    }
    collection.access = { ...collection.access, ...importCustomConfig.access }
    return collection
  },
  overrideImportCollection: ({ collection }) => {
    const exportCustomConfig = {
      access: {
        read: ({ req }) => true,
      },
      upload: {
        disableLocalStorage: true,
      },
      admin: {[
        group: 'System',
        defaultColumns: [
          'id',
          'filename',
          'filesize',
          'createdAt',
          'mimeType',
          'collectionSlug',
          'importMode',
          'matchField',
          'status',
        ],
      },
      labels: {
        singular: {
          ja: 'エックスポート',
          en: 'Export',
        },
        plural: {
          ja: 'エックスポート',
          en: 'Exports',
        },
      },
    } satisfies Partial<CollectionConfig>

    if (collection.admin) {
      collection.admin = {
        ...collection.admin,
        ...exportCustomConfig.admin,
      }
    } else {
      collection.admin = {
        ...exportCustomConfig.admin,
      }
    }
    collection.access = { ...collection.access, ...exportCustomConfig.access }
    return collection
  },
  collections: AllowImportExportCollections.map((collectionSlug) => ({
    slug: collectionSlug,
    import: {
    },
    export: {},
  })),
  debug: true, // debug remains top level
})

le

Link to the code that reproduces this issue

https://github.com/anhdd-kuro/use-document-info-test

Reproduction Steps

Login as: admin@example.com / 123456
Just export posts, then import.
The job does not get created because it fails to load the local file.

Which area(s) are affected?

plugin: import-export

Environment Info

Binaries:
  Node: 25.2.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.24.0
Relevant Packages:
  payload: 3.71.1
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions