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

Files being referenced by URL are not working Linux Issue #10

Open
pedantix opened this issue Aug 4, 2018 · 2 comments
Open

Files being referenced by URL are not working Linux Issue #10

pedantix opened this issue Aug 4, 2018 · 2 comments

Comments

@pedantix
Copy link

pedantix commented Aug 4, 2018

Hi! Thanks for the awesome project! So I had this issue where everything worked great on Mac but then when I deployed to a Linux environment I had issues. Uploads were happening but the Data sets were zero. So I investgated and found that this line may be the potential culprit:

https://github.com/LiveUI/S3/blob/master/Sources/S3/Extensions/S3%2BPut.swift#L50
in particular let data: Data = try Data(contentsOf: url)

I checked on swift-corelibs-foundation and found that that was fully implemented so it lead me to wonder if there is something different in the way in which Data is poplulated between the two libraries and what I found was a bit interesting.

I switched my code to do the following:

try req.client().get(url).flatMap(to: File.Response.self) { resp in
            guard let data = resp.http.body.data else {
                throw VGSMError(identifier: "unable to access user image data",
                                reason: "Failure in request mostlikely the readson",
                                source:.capture())
            }
            let file = File.Upload(data: data, destination: destination, access: .publicRead)
            return try req.makeS3Client().put(file: file, on: req)
            }

It was the following.

        return try s3Client.put(file: URL(string: url)!,
                     destination: "image.txt",
                     access: .publicRead,
                     on: req)
                     .map { resp in
                        print("Resp \(resp)")
                        return user
        }

    }

After the switch my code worked just fine.

@rafiki270 you may want to consider using the container Client to request the data here if you wanted I could put a PR together that would change this functionality.

@rafiki270
Copy link
Collaborator

thats a pity ... hmm ... a PR would be obviously fantastic

@pedantix
Copy link
Author

pedantix commented Aug 8, 2018

👍

@pedantix pedantix closed this as completed Aug 8, 2018
@pedantix pedantix reopened this Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants