Closed ipodishima closed 2 months ago
Hi @ipodishima, thanks for opening this issue.
I quickly tried on a simple project and was not able to reproduce this issue following your steps: downloadData(path:)
completed successfully.
However, looking at your code snippets I noticed some things that might be causing your issue:
1· After calling uploadData(path:data:)
, you are not waiting for the task to complete
let uploadPath = try await uploadTask.value
If you immediately call downloadData(path:)
after creating the uploadTask
, the actual upload might have not finished yet, so you'd get an error. However this would likely give you a 404 error, so perhaps it's not the actual problem.
2· In your workaround function, it seems you were previously calling the deprecated downloadData(key:)
function instead of downloadData(path:)
, which is the one you should use since you're using Gen2 and you've also uploaded the data using path
instead of key
.
This also can likely explain the 403 error, as using key
will attempt to access the public/
folder by default, for which you did not define permissions in your backend.
Could you please confirm if either of these is the culprit? If the error still persists, then could you please provide the verbose logs when you perform the steps? You can enable it by doing
Amplify.Logging.logLevel = .verbose
Thanks!
Heyyyy
Thanks for the really quick response.
Yes, I do wait for the upload to complete, just forgot to paste it.
Tested with
let downloadTask = Amplify.Storage.downloadData(path: .fromString(key))
And I don't get a 403!
However
Source code doesn't flag this as deprecated nor does the documentation says anything about public
which I think is confusing
I just checked the documentation and actually my bad, did not saw that auto completion selected key
instead of path
and I failed here ahah
Oh. Funny
In StorageCategoryBehavior
protocol, it's flagged as deprecated
Maybe that
public static internal(set) var Storage = StorageCategory()
should be
public static internal(set) var Storage: StorageCategoryBehavior = StorageCategory()
To get the compiler deprecation help?
[EDIT] I confirmed with using private let storage: StorageCategoryBehavior = Amplify.Storage
instead of Amplify.Storage
directly BUT you're losing default parameters
Great to hear the issue's been solved!
And thanks for bringing up the function not being marked as deprecated on Xcode. It's probably related to what you've said and we just need to mark the actual implementation as deprecated as well.
Regarding the public/
folder, in case you're interested, that's just one of the folders that Amplify Gen1 defines by default. When using key
s in the Amplify APIs, these folders were not meant to be included as part of the key but rather configured as accessLevel
s in the API options, with .guest
being the default. But all of these is now deprecated and path
is the way to go :)
We will take a look at ensuring these old APIs appear as deprecated when attempted to use, but in the meantime I'll close this issue as the actual error has been resolved.
Thanks!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
Hey
I noticed something really weird which took me a while to figure out (I didn't required to save the data to a file, so I was looking for other issues like misconfiguration).
After uploading a file, if you download it as data, you get a 403.
If I download the same file, same key, to a local url or if I generate a presigned url and download it, it works perfectly.
Steps To Reproduce
You'll get
And it work perfectly.
NB: My workaround for now is