1

私は次のことを試しました:

f = default_storage.open('test/', 'w')
f.write('')
f.close()

しかし、それはこのエラーを返しました:

提供された XML は整形式ではなかったか、公開されたスキーマに対して検証されませんでした

4

2 に答える 2

3

S3にはフォルダのようなものはありません。パスを使用してファイルを保存すると、ディレクトリ構造が「偽造」されます。

https://stackoverflow.com/a/2141499/682968

Amazon s3 バケットにフォルダーを追加する

于 2013-04-25T12:42:13.557 に答える
0

For Google Cloud Storage I ended up creating the directory by overriding the save method for which the writing of an empty file works:


class Attachment(models.Model):
    file = models.FileField(...)

    def save(self, *args, **kwargs):
        super(Attachment, self).save(*args, **kwargs)

        cloud_storage = GoogleCloudStorage(...)
        directory_path = "<your_path>"
        if not cloud_storage.exists(directory_path):
            directory = cloud_storage.open(directory_path, "w")
            directory.write("")
            directory.close()
于 2020-01-14T08:43:06.567 に答える