# Saving array of objects containing ParseFiles

**URL:** <https://community.parseplatform.org/t/saving-array-of-objects-containing-parsefiles/2951>\
**Category:** ParseSwift SDK\
**Created:** [September 29, 2022, 2:39am UTC](https://community.parseplatform.org/t/saving-array-of-objects-containing-parsefiles/2951 "2022-09-29T02:39:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcbeta](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/b/ba8739/32.png) [@bcbeta](https://community.parseplatform.org/u/bcbeta)\
**Post date:** [September 29, 2022, 2:39am UTC](https://community.parseplatform.org/t/saving-array-of-objects-containing-parsefiles/2951/1 "2022-09-29T02:39:48Z")

</div>

I have a PFPhoto object which contains 2 ParseFiles:

```auto
struct PFPhoto: ParseObject {
    //: These are required by ParseObject
    var objectId: String?
    var createdAt: Date?
    var updatedAt: Date?
    var ACL: ParseACL?
    var originalData: Data?

    //: Your own properties.
    var photo: ParseFile?
    var thumbnail: ParseFile?
    var location: ParseGeoPoint?
}

```

If I create and save this object, everything works fine:

```auto
 let photoFile = ParseFile(name:"photo.jpg", data: photoData as Data)
 let thumbnailFile = ParseFile(name:"thumbnail.jpg", data: thumbnailImageData)
                
 var pfPhoto = PFPhoto()
 var photoACL = ParseACL()
 photoACL.publicRead = true
 photoACL.publicWrite = false
 photoACL.setWriteAccess(user: User.current!, value: true)
                
 pfPhoto.ACL = photoACL
 pfPhoto.photo = photoFile
 pfPhoto.thumbnail = thumbnailFile
 pfPhoto.save() { result in
       print("photo saved")
        }

```

I have a PFTour object which links to an array of PFPhoto’s:

```auto
struct PFTour: ParseObject {
    
    //: These are required by ParseObject
    var objectId: String?
    var createdAt: Date?
    var updatedAt: Date?
    var ACL: ParseACL?
    var originalData: Data?

    //: Your own properties.
    var name: String?
    var photos: [PFPhoto]?
}

```

When I add the PFPhotos to the tour and save the PFTour, the objects are all created but the ParseFile data is invalid- [https://parsefiles.back4app.com/zgqRRfY6Tr5ICfdPocRLZG8EXK59vfS5dpDM5bqr/thumbnail.jpg](https://parsefiles.back4app.com/zgqRRfY6Tr5ICfdPocRLZG8EXK59vfS5dpDM5bqr/thumbnail.jpg)

```auto
  var pfTour = PFTour()
  var tourACL = ParseACL() 
  tourACL.publicRead = true
  tourACL.publicWrite = false
  tourACL.setWriteAccess(user: User.current!, value: true)
  pfTour.ACL = tourACL
  let photos = self.fetchPhotos(fromTour: tourID, to: pfTour, in: backgroundContext)
  pfTour.photos = photos

```

Is what I’m doing allowed or is there a better way to go about it?
