Skip to content

Nested ParseFile saves invalid data #425

Open
@bcbeta

Description

@bcbeta

Issue Description

Deep save of ParseFile creates invalid file.

Steps to reproduce

Adopted from the Files playground. Instead of the ParseFile profilePicture property I created a property that links to a PFPhoto object with nested ParseFiles:

struct GameScore: ParseObject {
    var objectId: String?
    var createdAt: Date?
    var updatedAt: Date?
    var ACL: ParseACL?
    var originalData: Data?

    //: Your own properties.
    var points: Int? = 0
    var photo: PFPhoto?
}
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?
}

I then save a Score that contains the PFPhoto:

var score = GameScore(points: 52)
        //: Set the link online for the file.
        let linkToFile = URL(string: "https://parseplatform.org/img/logo.svg")!

        //: Create a new `ParseFile` for your picture.

        //: Set the picture as part of your ParseObject
        let photoFile = ParseFile(name: "profile.svg", cloudURL: linkToFile)
         let thumbnailFile = ParseFile(name: "profile.svg", cloudURL: linkToFile)
        
        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
        score.photo = pfPhoto

            do {
                try await score.save()
            }
            catch{
                print(error.localizedDescription)
            }

Actual Outcome

When I save a score object, the PFPhoto object is saved but the ParseFiles link to invalid data- https://parsefiles.back4app.com/zgqRRfY6Tr5ICfdPocRLZG8EXK59vfS5dpDM5bqr/thumbnail.jpg

Expected Outcome

The PFPhoto object should contain two valid image files.

Environment

Client

  • Parse Swift SDK version: 4.14.2
  • Xcode version: 14.0.1
  • Operating system (iOS, macOS, watchOS, etc.): iOS 16

Server

  • Parse Server version: 4.5.0
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): back4app

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions