-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Transfer-Encoding Header For PUT request to AWS S3 #94
Comments
@MQZhangThu , thanks for reporting the issue 👍 looks like it's related to square/okhttp#2190, there's already a PR(#86) to solve this issue, but I don't have time to test and merge it, I'll update the status in this thread once it got merged. |
After some test, I found that when simply overrides |
👍 so what is the recommend way to set the content length? One possible way is seting the "content-length" header as the byte number when calling RNFetchBlob.fetch? However, this may be a little weird, as in my opinion, the "content-length" should be set by RNFetchBlob lib itself, not by the user. :) |
Yeah, but I can't calculate correct content length from multipart body so far, I think it might takes some time. |
@MQZhangThu , I've published |
@wkh237 It works now. Great. But the |
@MQZhangThu , thank you for the information, I've fixed the bug in |
I'm getting 501:s when trying to |
@adbl , IOS network module should not send chunked request, is there any way for me to reproduce this issue ? |
hmm, pretty complicated if you're not already using signed AWS S3 urls. I would be able to debug it with XCode if you can give me some instructions? |
@adbl , after some investigation I know where's the problem now. In our IOS native implementation, if you use an URI as the request body (use RNFetchBlob.wrap), we will create a file stream for it then pipe it to request stream for better memory efficiency (refer to the implementation). However, the API we use (NSURLSession) will automatically use let rnfbURI = RNFetchBlob.wrap(pathOfAFile)
RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload`, {}, rnfbURI) which wil send a request with the following headers however, if we change the way we send request, use BASE64 encoded data RNFetchBlob .fetch('POST', `${TEST_SERVER_URL}/upload`, {
'Content-Type' : 'application/octet-stream;BASE64'
}, base64) it no longer send chunked request there's no such an option to manually change the way it send request at this moment, but I think it's great to add one so that it can be more flexible. If you have any idea about the concept please feel free to leave any comment, thank you 😄 |
Aha, is it possible to tell For my purposes, bas64 is no-go. |
From my understanding, if not using In fact there's an fs API |
Aha cool, that's great when uploading big files. Our particular use case they are only around 400kb. Would it be feasible to implement this force thing (I guess that means it have to read the file into memory to calculate length. But for small files that might be ok? |
As long as it's done in native I mean. |
You may take a look at this issue. The way that FireBase SDK deal with different size files, it send the file in single request if the size is smaller than 256kb otherwise it splits the file into 256kb chunks then upload them separately. I think this is a good reference 😏 On the other hand, I will add an additional option for developers to switch on/off |
Nice! |
The fix has been released with |
I used pre-singed url to PUT image to AWS S3. The PUT request did not work out, and the AWS S3 response is 501 Error, saying that "Transfer-Encoding: Chunked" Header is not implemented.
Anyone knows how to solve this problem? Thx.
The text was updated successfully, but these errors were encountered: