所以我升级到Android Studio 0.8.14并且我已经知道我可以在我的模块app/src/newbuildtype上创建一个新文件夹,在那里我可以创建文件夹java和res特定于我的构建类型,但我想要的是直接从Android Studio创建资源.有没有办法做到这一点?我想避免的是直接用我的文件浏览器创建文件夹,谢谢.
我已经看到了几个使用react-native-fetch-blob上传资源作为表单数据上传文件的例子,遗憾的是我需要上传到的服务器不支持多部分,而是文件的二进制流.我正在使用react native(dettached)并创建了一个本机模块(iOS),它返回本地标识符和要上载的文件的本地路径,例如:
4697EAE5-50A3-4462-AE5A-71CC5D08C2D7/L0/001: file:///var/mobile/Media/DCIM/100APPLE/IMG_0038.JPG
Run Code Online (Sandbox Code Playgroud)
但是,当我指定要上传的库的路径时,它会上传一个空流,服务器会存储一个零字节大小的文件,我正在上传我正在做的事情的片段:
export const uploadFile = (
action,
url,
data,
showLoading = true,
showError = true
) => (dispatch, getStore) => { // in the future it's going to be connected to redux
const uploadPath = RNFetchBlob.wrap(data.replace("file://", ""));
// uploadPath = "RNFetchBlob-file:///var/mobile/Media/DCIM/100APPLE/IMG_0033.JPG"
console.log("path to upload", uploadPath);
return RNFetchBlob.fetch(
"PUT",
url,
{
// appends the Bearer token of the server
...getConfigFromStore(getStore()).headers
"Content-Type": "application/octet-stream"
},
uploadPath
)
.then(response => console.log("response ok", response))
.catch(error => console.error("response error", error)); …Run Code Online (Sandbox Code Playgroud)