我是Dim module As Object
Sub Main()
Call Stic1
Call Stic2
End Sub
Sub Stic1()
Dim x As String
Dim n As Integer, c As Integer
x = "Minimum"
Sheets("Ts").Select
Range("A2").Offset(0, 0).Select
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value = x Then
ActiveCell.Offset(0, 1).Copy
Application.Goto (ActiveWorkbook.Sheets("Rs").Range("G2").Offset(n, 0))
ActiveSheet.Paste
Application.CutCopyMode = False
n = n + 1
Application.Goto (ActiveWorkbook.Sheets("Ts").Range("A2").Offset(c, 0))
c = c + 1
Else
Application.Goto (ActiveWorkbook.Sheets("Ts").Range("A2").Offset(c, 0))
c = c + 1
End If
Application.Goto (ActiveWorkbook.Sheets("Ts").Range("A2").Offset(c, 0))
Loop
End Sub
Sub Stic2()
Dim x As String
Dim n As Integer, c As Integer
x = "Minimum"
Sheets("BR").Select
Range("A2").Offset(0, 0).Select
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value = x Then
ActiveCell.Offset(0, 1).Copy
Application.Goto (ActiveWorkbook.Sheets("Rs").Range("I2").Offset(n, 0))
ActiveSheet.Paste
Application.CutCopyMode = False
n = n + 1
Application.Goto (ActiveWorkbook.Sheets("BR").Range("A2").Offset(c, 0))
c = c + 1
Else
Application.Goto (ActiveWorkbook.Sheets("BR").Range("A2").Offset(c, 0))
c = c + 1
End If
Application.Goto (ActiveWorkbook.Sheets("BR").Range("A2").Offset(c, 0))
Loop
End Sub
中的新手,在这段代码中,我想将文件作为图像或其他格式上传到服务器,我阅读了有关该文件的改造文件,但我无法做到,
我可以创建提供程序,我可以将其用于服务器的retrofit
或POST
,但我的问题是上传文件。
感谢提前
我的GET
课程:
SignalProvider
我的public class SignalProvider {
private SignalRetrofitServiceProviders signalRetrofitServiceProviders;
public SignalProvider(){
OkHttpClient httpClient = new OkHttpClient();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ClientSettings.SignalWebBaseUrl)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
signalRetrofitServiceProviders = retrofit.create(SignalRetrofitServiceProviders.class);
}
public SignalRetrofitServiceProviders getServices(){
return signalRetrofitServiceProviders;
}
}
课程:
SignalRetrofitServiceProviders
然后上传文件方法:
public interface SignalRetrofitServiceProviders {
@POST("storeLists")
Call<List<StoreLists>> getStoreLists();
@Multipart
@POST("upload/newVitrine/{userId}")
Call<ResponseBody> uploadImageToServer(
@Path("id") int id,
@Part("description")
RequestBody description,
@Part MultipartBody.Part file);
}
我收到此错误:
private void uploadFile() {
// create upload service client
SignalProvider signalProvider = new SignalProvider();
SignalRetrofitServiceProviders service = signalProvider.getServices();
File file = new File(Application.IMAGES + "/" + "test_image.jpg");
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part body = MultipartBody.Part.createFormData("picture", file.getName(), requestFile);
String descriptionString = "hello, this is description speaking";
RequestBody description = RequestBody.create(
MediaType.parse("multipart/form-data"), descriptionString);
Call<ResponseBody> call = service.uploadImageToServer("1",description, body);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call,
Response<ResponseBody> response) {
Log.e("Upload", "success");
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e("Upload error:", t.getMessage());
}
});
}
答案 0 :(得分:1)
我认为需要解决的首要问题之一是您的上传路线Edit
在路径中包含@POST("upload/newVitrine/{userId}")
,但您的userId
仅包含“id”和“描述”。
另外,我们可以看到您的进口商品吗?