Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested ParseFile saves invalid data #425

Open
bcbeta opened this issue Oct 12, 2022 · 1 comment
Open

Nested ParseFile saves invalid data #425

bcbeta opened this issue Oct 12, 2022 · 1 comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@bcbeta
Copy link

bcbeta commented Oct 12, 2022

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
@parse-github-assistant
Copy link

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@cbaker6 cbaker6 added the type:bug Impaired feature or lacking behavior that is likely assumed label Oct 12, 2022
@mtrezza mtrezza added the bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) label Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants